github.com/koko1123/flow-go-1@v0.29.6/utils/unittest/fvm.go (about) 1 package unittest 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 "github.com/koko1123/flow-go-1/fvm/systemcontracts" 9 "github.com/koko1123/flow-go-1/model/flow" 10 ) 11 12 func IsServiceEvent(event flow.Event, chainID flow.ChainID) bool { 13 serviceEvents, _ := systemcontracts.ServiceEventsForChain(chainID) 14 for _, serviceEvent := range serviceEvents.All() { 15 if serviceEvent.EventType() == event.Type { 16 return true 17 } 18 } 19 return false 20 } 21 22 // EnsureEventsIndexSeq checks if values of given event index sequence are monotonically increasing. 23 func EnsureEventsIndexSeq(t *testing.T, events []flow.Event, chainID flow.ChainID) { 24 expectedEventIndex := uint32(0) 25 for _, event := range events { 26 require.Equal(t, expectedEventIndex, event.EventIndex) 27 if IsServiceEvent(event, chainID) { 28 // TODO: we will need to address the double counting issue for service events. 29 // https://github.com/koko1123/flow-go-1/issues/3393 30 expectedEventIndex += 2 31 } else { 32 expectedEventIndex++ 33 } 34 } 35 }