-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathqubic_integration_test.go
More file actions
173 lines (141 loc) · 6.34 KB
/
qubic_integration_test.go
File metadata and controls
173 lines (141 loc) · 6.34 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//go:build !ci
// +build !ci
package qubic
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const UniverseIndexOfRandom = 41 // can change over time
var nodeIp = "5.9.16.14"
func TestQubicIntegration_GetAssetIssuancesByUniverseIndexPayload(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
issuances, err := client.GetAssetIssuancesByUniverseIndex(context.Background(), UniverseIndexOfRandom)
assert.NoError(t, err)
assert.Len(t, issuances, 1)
issuance := issuances[0]
assert.Equal(t, UniverseIndexOfRandom, int(issuance.UniverseIndex))
assert.Greater(t, issuance.Tick, uint32(20173192)) // ep 150 start
asset := issuance.Asset
assert.Equal(t, 0, int(asset.NumberOfDecimalPlaces))
assert.Equal(t, [7]int8{82, 65, 78, 68, 79, 77, 0}, asset.Name) // RANDOM
assert.Equal(t, [7]int8{0, 0, 0, 0, 0, 0, 0}, asset.UnitOfMeasurement)
assert.Equal(t, [32]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, asset.PublicKey)
assert.Equal(t, uint8(1), asset.Type)
}
func TestQubicIntegration_GetAssetOwnershipsByUniverseIndexPayload(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
ownerships, err := client.GetAssetOwnershipsByUniverseIndex(context.Background(), 16697282)
assert.NoError(t, err)
assert.Len(t, ownerships, 1)
ownership := ownerships[0]
assert.Equal(t, 16697282, int(ownership.UniverseIndex))
assert.Positive(t, ownership.UniverseIndex)
assert.Greater(t, ownership.Tick, uint32(20173192)) // ep 150 start
asset := ownership.Asset
assert.Equal(t, asset.ManagingContractIndex, uint16(1)) // 1 = QX
assert.Equal(t, byte(2), asset.Type) // ownership type
assert.Equal(t, UniverseIndexOfRandom, int(asset.IssuanceIndex)) // RANDOM
// owner information
assert.Positive(t, asset.NumberOfUnits)
assert.Len(t, asset.PublicKey, 32)
}
func TestQubicIntegration_GetPossessionsByUniverseIndexPayload(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
possessions, err := client.GetAssetPossessionsByUniverseIndex(context.Background(), 16697283)
assert.NoError(t, err)
assert.Len(t, possessions, 1)
possession := possessions[0] // take first
assert.Positive(t, possession.UniverseIndex)
assert.Equal(t, 16697283, int(possession.UniverseIndex))
assert.Greater(t, possession.Tick, uint32(20173192)) // ep 150 start
asset := possession.Asset
assert.Equal(t, asset.ManagingContractIndex, uint16(1)) // 1 = QX
assert.Equal(t, byte(3), asset.Type) // possession type
assert.Positive(t, asset.OwnershipIndex) // RANDOM
// owner information
assert.GreaterOrEqual(t, asset.NumberOfUnits, int64(1))
assert.Len(t, asset.PublicKey, 32)
}
func TestQubicIntegration_GetAssetIssuancesByFilter(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
issuances, err := client.GetAssetIssuancesByFilter(context.Background(), "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFXIB", "RANDOM")
assert.NoError(t, err)
assert.Len(t, issuances, 1)
issuance := issuances[0]
assert.Equal(t, UniverseIndexOfRandom, int(issuance.UniverseIndex)) // universe index can change over time
assert.Greater(t, issuance.Tick, uint32(20173192)) // ep 150 start
asset := issuance.Asset
assert.Equal(t, int8(0), asset.NumberOfDecimalPlaces)
assert.Equal(t, [7]int8{82, 65, 78, 68, 79, 77, 0}, asset.Name) // RANDOM
assert.Equal(t, [7]int8{0, 0, 0, 0, 0, 0, 0}, asset.UnitOfMeasurement)
assert.Equal(t, [32]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, asset.PublicKey)
assert.Equal(t, uint8(1), asset.Type) // issuance type
}
func TestQubicIntegration_GetAssetOwnershipsByFilter(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
ownerships, err := client.GetAssetOwnershipsByFilter(context.Background(),
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFXIB",
"RANDOM",
"",
1)
assert.NoError(t, err)
assert.NotEmpty(t, ownerships)
ownership := ownerships[0]
assert.Positive(t, ownership.UniverseIndex)
//assert.Equal(t, 16697282, int(ownership.UniverseIndex))
assert.Greater(t, ownership.Tick, uint32(20173192)) // ep 150 start
asset := ownership.Asset
assert.Equal(t, asset.ManagingContractIndex, uint16(1)) // 1 = QX
assert.Equal(t, byte(2), asset.Type) // ownership type
assert.Equal(t, UniverseIndexOfRandom, int(asset.IssuanceIndex)) // RANDOM
// owner information
assert.Positive(t, asset.NumberOfUnits)
assert.Len(t, asset.PublicKey, 32)
}
func TestQubicIntegration_GetAssetPossessionsByFilter(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
assert.NoError(t, err)
possessions, err := client.GetAssetPossessionsByFilter(context.Background(),
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFXIB",
"RANDOM",
"",
"",
1,
1)
assert.NoError(t, err)
assert.NotEmpty(t, possessions)
possession := possessions[0] // take first
assert.Positive(t, possession.UniverseIndex)
//assert.Equal(t, 16697283, int(possession.UniverseIndex))
assert.Greater(t, possession.Tick, uint32(20173192)) // ep 150 start
asset := possession.Asset
assert.Equal(t, asset.ManagingContractIndex, uint16(1)) // 1 = QX
assert.Equal(t, byte(3), asset.Type) // possession type
assert.Positive(t, asset.OwnershipIndex) // RANDOM
// owner information
assert.GreaterOrEqual(t, asset.NumberOfUnits, int64(1))
assert.Len(t, asset.PublicKey, 32)
}
func TestQubicIntegration_GetOwnedAssets(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
require.NoError(t, err)
// doesn't own any assets
assets, err := client.GetOwnedAssets(context.Background(), "RHMWVHLCFWMAHENMIHVLXHPGPGRCYTZQYZPRYBWDFDJMLXCZDFVETDUFHDSC")
require.NoError(t, err)
assert.Nil(t, assets)
}
func TestQubicIntegration_GetActiveIpos(t *testing.T) {
client, err := NewClient(context.Background(), nodeIp, "21841")
require.NoError(t, err)
// returns nil if there are no active ipos
ipos, err := client.GetActiveIpos(context.Background())
require.NoError(t, err)
assert.Nil(t, ipos)
}