-
Notifications
You must be signed in to change notification settings - Fork 8
/
dandy_test.go
136 lines (110 loc) · 3.72 KB
/
dandy_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
133
134
135
136
package test_main
import (
"testing"
. "github.com/bjartek/overflow"
"github.com/hexops/autogold"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
)
/*
Tests must be in the same folder as flow.json with contracts and transactions/scripts in subdirectories in order for the path resolver to work correctly
*/
func TestDandy(t *testing.T) {
otu := NewOverflowTest(t).
setupFIND().
setupDandy("user1").
createUser(100.0, "user2").
registerUser("user2")
t.Run("Should be able to mint 3 dandy nfts and display them", func(t *testing.T) {
otu.setUUID(500)
dandyIds := otu.mintThreeExampleDandies()
otu.registerFtInRegistry()
id := dandyIds[0]
viewList := []string{
otu.identifier("FindViews", "Nounce"),
otu.identifier("MetadataViews", "NFTCollectionData"),
otu.identifier("MetadataViews", "NFTCollectionDisplay"),
otu.identifier("MetadataViews", "Display"),
otu.identifier("MetadataViews", "Royalties"),
otu.identifier("MetadataViews", "Editions"),
otu.identifier("MetadataViews", "Traits"),
otu.identifier("MetadataViews", "ExternalURL"),
otu.identifier("MetadataViews", "CreativeWork"),
otu.identifier("MetadataViews", "Medias"),
}
res, err := otu.O.Script("getNFTViews",
WithArg("user", "user1"),
WithArg("aliasOrIdentifier", dandyNFTType(otu)),
WithArg("id", id),
).
GetAsInterface()
require.NoError(t, err)
resList, ok := res.([]interface{})
require.True(t, ok)
for _, item := range resList {
stringItem := item.(string)
slices.Contains(viewList, stringItem)
}
otu.O.Script("getNFTView",
WithArg("user", "user1"),
WithArg("aliasOrIdentifier", dandyNFTType(otu)),
WithArg("id", id),
WithArg("identifier", otu.identifier("MetadataViews", "Display")),
).AssertWant(t,
autogold.Want("Display", map[string]interface{}{
"description": "Bringing the motorcycle world into the 21st century with cutting edge EV technology and advanced performance in a great classic British style, all here in the UK",
"name": "Neo Motorcycle 1 of 3",
"thumbnail": map[string]interface{}{"url": "https://neomotorcycles.co.uk/assets/img/neo_motorcycle_side.webp"},
}),
)
otu.O.Script("getNFTView",
WithArg("user", "user1"),
WithArg("aliasOrIdentifier", dandyNFTType(otu)),
WithArg("id", id),
WithArg("identifier", otu.identifier("MetadataViews", "ExternalURL")),
).AssertWant(t,
autogold.Want("ExternalURL", map[string]interface{}{"url": "https://find.xyz/collection/user1/dandy/502"}),
)
for _, dandy := range dandyIds {
otu.sendDandy("user2", "user1", dandy)
}
})
/* Test on dandy nft indexing {Mapping of minter} */
t.Run("Should be able to return the correct minter and dandies list", func(t *testing.T) {
otu.setUUID(700)
dandiesIDs := otu.mintThreeExampleDandies()
result, err := otu.O.Script("getDandiesIDsFor",
WithArg("user", "user1"),
WithArg("minter", "user1"),
).GetAsInterface()
if err != nil {
panic(err)
}
assert.ElementsMatch(t, result, []interface{}{uint64(702), uint64(703), uint64(704)})
otu.O.Script("getDandiesMinters",
WithArg("user", "user1"),
).AssertWant(t,
autogold.Want("dandyMinters", `[]interface {}{
"user1",
}`),
)
/* mint new dandies and withdraw all of them */
dandiesIDs = append(dandiesIDs, otu.mintThreeExampleDandies()...)
otu.O.Tx("devDestroyDandies",
WithSigner("user1"),
WithArg("ids", dandiesIDs),
).AssertSuccess(t)
otu.O.Script("getDandiesIDsFor",
WithArg("user", "user1"),
WithArg("minter", "user1"),
).AssertWant(t,
autogold.Want("noDandies", nil),
)
otu.O.Script("getDandiesMinters",
WithArg("user", "user1"),
).AssertWant(t,
autogold.Want("noDandyMinters", nil),
)
})
}