forked from dapperlabs/nba-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubedition_added_to_moment_test.go
49 lines (40 loc) · 1.36 KB
/
subedition_added_to_moment_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
package events
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/onflow/cadence"
jsoncdc "github.com/onflow/cadence/encoding/json"
"github.com/onflow/cadence/runtime/tests/utils"
"github.com/stretchr/testify/assert"
)
func TestCadenceEvents_SubeditionAddedToMoment(t *testing.T) {
var (
subeditionID = uint32(1234)
momentID = uint64(1234)
)
playCreatedEventType := cadence.EventType{
Location: utils.TestLocation,
QualifiedIdentifier: "TopShot.SubeditionAddedToMoment",
Fields: []cadence.Field{
{
Identifier: "momentID",
Type: cadence.UInt64Type{},
},
{
Identifier: "subeditionID",
Type: cadence.UInt32Type{},
},
},
Initializer: []cadence.Parameter{},
}
subeditionAddedToMomentEvent := cadence.NewEvent([]cadence.Value{
cadence.NewUInt64(momentID),
cadence.NewUInt32(subeditionID),
}).WithType(&playCreatedEventType)
payload, err := jsoncdc.Encode(subeditionAddedToMomentEvent)
require.NoError(t, err, "failed to encode subedition added to moment cadence event")
decodedPlayCreatedEventType, err := DecodeSubeditionAddedToMomentEvent(payload)
require.NoError(t, err, "failed to decode subedition added to moment cadence event")
assert.Equal(t, momentID, decodedPlayCreatedEventType.MomentID())
assert.Equal(t, subeditionID, decodedPlayCreatedEventType.SubeditionID())
}