github.com/koko1123/flow-go-1@v0.29.6/model/convert/service_event_test.go (about) 1 package convert_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 "github.com/koko1123/flow-go-1/model/convert" 10 "github.com/koko1123/flow-go-1/model/convert/fixtures" 11 "github.com/koko1123/flow-go-1/model/flow" 12 ) 13 14 func TestEventConversion(t *testing.T) { 15 16 chainID := flow.Emulator 17 18 t.Run("epoch setup", func(t *testing.T) { 19 20 fixture, expected := fixtures.EpochSetupFixtureByChainID(chainID) 21 22 // convert Cadence types to Go types 23 event, err := convert.ServiceEvent(chainID, fixture) 24 require.NoError(t, err) 25 require.NotNil(t, event) 26 27 // cast event type to epoch setup 28 actual, ok := event.Event.(*flow.EpochSetup) 29 require.True(t, ok) 30 31 assert.Equal(t, expected, actual) 32 33 }) 34 35 t.Run("epoch commit", func(t *testing.T) { 36 37 fixture, expected := fixtures.EpochCommitFixtureByChainID(chainID) 38 39 // convert Cadence types to Go types 40 event, err := convert.ServiceEvent(chainID, fixture) 41 require.NoError(t, err) 42 require.NotNil(t, event) 43 44 // cast event type to epoch commit 45 actual, ok := event.Event.(*flow.EpochCommit) 46 require.True(t, ok) 47 48 assert.Equal(t, expected, actual) 49 }) 50 }