-
Notifications
You must be signed in to change notification settings - Fork 8
/
collection_test.go
95 lines (71 loc) · 2.44 KB
/
collection_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
package test_main
import (
"fmt"
"testing"
. "github.com/bjartek/overflow"
"github.com/hexops/autogold"
"github.com/stretchr/testify/assert"
)
func TestCollectionScripts(t *testing.T) {
otu := NewOverflowTest(t)
otu.setupFIND().
createUser(10000.0, "user1").
registerUser("user1").
buyForge("user1").
registerUserWithNameAndForge("user1", "neomotorcycle").
registerUserWithNameAndForge("user1", "xtingles").
registerUserWithNameAndForge("user1", "flovatar").
registerUserWithNameAndForge("user1", "ufcstrike").
registerUserWithNameAndForge("user1", "jambb").
registerUserWithNameAndForge("user1", "bitku").
registerUserWithNameAndForge("user1", "goatedgoats").
registerUserWithNameAndForge("user1", "klktn")
otu.setUUID(500)
otu.O.Tx("devMintDandyTO",
WithSigner("user1"),
WithArg("name", "user1"),
WithArg("maxEdition", 1),
WithArg("artist", "Neo"),
WithArg("nftName", "Motorcycle"),
WithArg("nftDescription", `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`),
WithArg("nftUrl", "https://neomotorcycles.co.uk/assets/img/neo_motorcycle_side.webp"),
WithArg("rarity", "rare"),
WithArg("rarityNum", 50.0),
WithArg("to", "user1"),
).
AssertSuccess(t)
otu.registerDandyInNFTRegistry()
t.Run("Should be able to get dandies by script", func(t *testing.T) {
result, err := otu.O.Script("getNFTCatalogItems",
WithArg("user", "user1"),
WithArg("collectionIDs", map[string][]uint64{dandyNFTType(otu): {504, 505, 503, 506, 502, 507}}),
).GetWithPointer(fmt.Sprintf("/%s", dandyNFTType(otu)))
if err != nil {
panic(err)
}
autogold.Equal(t, result)
})
t.Run("Should be able to get soul bounded items by script", func(t *testing.T) {
otu.registerExampleNFTInNFTRegistry()
exampleNFTIden := exampleNFTType(otu)
ids, err := otu.O.Script("getNFTCatalogIDs",
WithArg("user", otu.O.Address("find")),
WithArg("collections", `[]`),
).
GetWithPointer(fmt.Sprintf("/%s/extraIDs", exampleNFTIden))
assert.NoError(t, err)
typedIds, ok := ids.([]interface{})
if !ok {
panic(ids)
}
result, err := otu.O.Script("getNFTCatalogItems",
WithArg("user", otu.O.Address("find")),
WithArg("collectionIDs", map[string]interface{}{exampleNFTIden: typedIds}),
).
GetWithPointer(fmt.Sprintf("/%s", exampleNFTIden))
if err != nil {
panic(err)
}
autogold.Equal(t, result)
})
}