-
Notifications
You must be signed in to change notification settings - Fork 20
/
upload_integration_test.go
132 lines (104 loc) · 14 KB
/
upload_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package overflow
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTransactionUpload(t *testing.T) {
g, err := OverflowTesting()
assert.NoError(t, err)
t.Run("Upload image file invalid file", func(t *testing.T) {
err := g.UploadImageAsDataUrl("testFile2.txt", "first")
assert.Error(t, err)
assert.Contains(t, err.Error(), "could not read imageFile testFile2.txt")
})
t.Run("Upload test file invalid file", func(t *testing.T) {
err := g.UploadFile("testFile2.txt", "first")
assert.Error(t, err)
assert.Contains(t, err.Error(), "could not read file testFile2.txt")
})
t.Run("Upload test file", func(t *testing.T) {
g.Tx("mint_tokens",
WithSignerServiceAccount(),
WithArg("recipient", "first"),
WithArg("amount", 100.0),
).AssertSuccess(t)
err := g.UploadFile("testdata/testFile.txt", "first")
assert.NoError(t, err)
g.Tx(`
import Debug from "../contracts/Debug.cdc"
transaction {
prepare(account: auth(LoadValue) &Account) {
var content= account.storage.load<String>(from: /storage/upload) ?? panic("could not load content")
Debug.log(content)
}
}`, WithSigner("first")).
AssertSuccess(t).
AssertDebugLog(t, "VGhpcyBpcyBhIGZpbGU=")
})
t.Run("Upload test image", func(t *testing.T) {
g.Tx("mint_tokens",
WithSignerServiceAccount(),
WithArg("recipient", "first"),
WithArg("amount", 100.0),
).AssertSuccess(t)
err := g.UploadImageAsDataUrl("testdata/pig.png", "first")
assert.NoError(t, err)
g.Tx(`
import Debug from "../contracts/Debug.cdc"
transaction {
prepare(account: auth(LoadValue) &Account) {
var content= account.storage.load<String>(from: /storage/upload) ?? panic("could not load content")
Debug.log(content)
}
}`, WithSigner("first")).
AssertSuccess(t).
AssertDebugLog(t, "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAfYUlEQVR4nN19d1hT2db+SiOhF8EgAqEIwUoZEUUQHBEUEPh0bCjq2EZHR1Ssn1zrjA5W1LHcYeQKthEbRUEUUUGUJoKiQgBFem9JIBCS8/tjhxAhxCREf3e+9+HhOTlnZ6113rP3PnuvvdYODsMwAGCz2ceOHUtKSsrJyens7CSTyRQKhdwDVVVVGo1mampqYmJiamqKDlRUVGAQwDCsvLy8sLCQwWAwGIzy8nImk8lisZhMJpPJ5PP56iIwMDCw7IGJiQmBQBiM6vb29tLS0o8fP378+BEdfPr0ic1md4qAw+GQyWQ7Ozs3N7egoCBVVVWB0ampqSYmJjLpw+PxdnZ2QUFBd+/ebW1txaRGeXn5mTNnpk+frqysLN+tKikpOTs7Hzt2rKSkRHq9ra2td+/eDQoKsrOzw+PxMmk0MTFJTU3FMAzHZrOtrKzKy8sBwNbUdDKdrqmiwuFyO7ncTi4XHbR3dZU3NHysq2vr6Ogvi0Ag2NnZeXl5LV++3MjISKy+/Pz86OjomJiY7Ozs/ldVyWSanp6GsrKGioo6haKhooIDYHI4be3t6H9ZQ4NY1WPGjPHz8/P19R0/frxYveXl5eHh4ffu3cvJyeHxeP0LaCgrmw4daqSrq6KkRCaRKCQSmURCB63t7WmFha8+fgQAIyOjgoIC3L59+/bs2QMAIYsWbfP1HZBeAABoYrFK6+s/1tW9KSt78vZtelFRJ5crvIrH42fOnLl69WovLy8CgcDj8dLS0mJiYmJiYkpKSkTlGOvqzrCxGWNkZDV8uNXw4YY6OjgcTrLq6ubmgqqqwqqqdxUVD/LyCquqRK8aGhr6+Pj4+fm5urqSSCQej3fv3r0///wzISGBz+cLi5FJpIkWF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KMAAAAASUVORK5CYII=")
})
t.Run("Download and upload file fails wrong url", func(t *testing.T) {
err := g.DownloadAndUploadFile("https://foo.bar", "first")
assert.Error(t, err)
assert.Contains(t, err.Error(), "dial tcp: lookup foo.ba")
})
t.Run("Download and upload imagefile fails wrong url", func(t *testing.T) {
err := g.DownloadImageAndUploadAsDataUrl("https://foo.bar", "first")
assert.Error(t, err)
assert.Contains(t, err.Error(), "dial tcp: lookup foo.ba")
})
t.Run("Download and upload file", func(t *testing.T) {
//need flow in account to upload image
g.Tx("mint_tokens",
WithSignerServiceAccount(),
WithArg("recipient", "first"),
WithArg("amount", 100.0),
).AssertSuccess(t)
err := g.DownloadAndUploadFile("https://httpbin.org/image/png", "first")
assert.NoError(t, err)
g.Tx(`
import Debug from "../contracts/Debug.cdc"
transaction {
prepare(account: auth(LoadValue) &Account) {
var content= account.storage.load<String>(from: /storage/upload) ?? panic("could not load content")
Debug.log(content)
}
}`, WithSigner("first")).
AssertSuccess(t)
})
t.Run("Download image and upload", func(t *testing.T) {
//need flow in account to upload image
g.Tx("mint_tokens",
WithSignerServiceAccount(),
WithArg("recipient", "first"),
WithArg("amount", 100.0),
).AssertSuccess(t)
err := g.DownloadImageAndUploadAsDataUrl("https://httpbin.org/image/png", "first")
assert.NoError(t, err)
g.Tx(`
import Debug from "../contracts/Debug.cdc"
transaction {
prepare(account: auth(LoadValue) &Account) {
var content= account.storage.load<String>(from: /storage/upload) ?? panic("could not load content")
Debug.log(content)
}
}`, WithSigner("first")).AssertSuccess(t)
})
}