github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/fvm.go (about) 1 package unittest 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 "github.com/onflow/flow-go/fvm/systemcontracts" 9 "github.com/onflow/flow-go/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/onflow/flow-go/issues/3393 30 expectedEventIndex += 2 31 } else { 32 expectedEventIndex++ 33 } 34 } 35 }