Skip to content

Commit

Permalink
Updated new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Dec 17, 2024
1 parent 17370c5 commit 5bd6eb4
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions pkg/types/interfacetests/chain_components_interface_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf
Test: func(t T) {
ctx := tests.Context(t)
cr := tester.GetContractReader(t)
cw := tester.GetContractWriter(t)

bindings := tester.GetBindings(t)

require.NoError(t, cr.Bind(ctx, bindings))
boundContract := BindingsByName(bindings, AnyContractName)[0]

expectedSequenceData := createMixedEventTypeSequence(t, tester, boundContract)
expectedSequenceData := createMixedEventTypeSequence(t, tester, cw, boundContract)

ts := &TestStruct{}
require.Eventually(t, func() bool {
Expand Down Expand Up @@ -204,12 +206,13 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf
Test: func(t T) {
ctx := tests.Context(t)
cr := tester.GetContractReader(t)
cw := tester.GetContractWriter(t)
bindings := tester.GetBindings(t)

require.NoError(t, cr.Bind(ctx, bindings))
bound := BindingsByName(bindings, AnyContractName)[0]

expectedSequenceData := createMixedEventTypeSequence(t, tester, bound)
expectedSequenceData := createMixedEventTypeSequence(t, tester, cw, bound)

var value values.Value
require.Eventually(t, func() bool {
Expand Down Expand Up @@ -268,12 +271,14 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf
Test: func(t T) {
ctx := tests.Context(t)
cr := tester.GetContractReader(t)
cw := tester.GetContractWriter(t)

bindings := tester.GetBindings(t)

require.NoError(t, cr.Bind(ctx, bindings))
boundContract := BindingsByName(bindings, AnyContractName)[0]

expectedSequenceData := createMixedEventTypeSequence(t, tester, boundContract)
expectedSequenceData := createMixedEventTypeSequence(t, tester, cw, boundContract)

ts := &TestStruct{}
require.Eventually(t, func() bool {
Expand Down Expand Up @@ -321,6 +326,7 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf
Test: func(t T) {
ctx := tests.Context(t)
cr := tester.GetContractReader(t)
cw := tester.GetContractWriter(t)
bindings := tester.GetBindings(t)

require.NoError(t, cr.Bind(ctx, bindings))
Expand All @@ -330,26 +336,26 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf

ts1 := CreateTestStruct[T](0, tester)
expectedSequenceData = append(expectedSequenceData, &ts1)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts1, boundContract, types.Unconfirmed)
ts2 := CreateTestStruct[T](1, tester)
expectedSequenceData = append(expectedSequenceData, &ts2)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts2, boundContract, types.Unconfirmed)

ds1 := SomeDynamicTopicEvent{Field: "1"}
expectedSequenceData = append(expectedSequenceData, &ds1)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEventWithDynamicTopic, ds1, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEventWithDynamicTopic, ds1, boundContract, types.Unconfirmed)

ts3 := CreateTestStruct[T](2, tester)
expectedSequenceData = append(expectedSequenceData, &ts3)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts3, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts3, boundContract, types.Unconfirmed)

ds2 := SomeDynamicTopicEvent{Field: "2"}
expectedSequenceData = append(expectedSequenceData, &ds2)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEventWithDynamicTopic, ds2, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEventWithDynamicTopic, ds2, boundContract, types.Unconfirmed)

ts4 := CreateTestStruct[T](3, tester)
expectedSequenceData = append(expectedSequenceData, &ts4)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts4, boundContract, types.Finalized)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts4, boundContract, types.Finalized)

require.Eventually(t, func() bool {
var allSequences []sequenceWithKey
Expand Down Expand Up @@ -402,31 +408,31 @@ func runQueryKeysInterfaceTests[T TestingT[T]](t T, tester ChainComponentsInterf
RunTests(t, tester, tests)
}

func createMixedEventTypeSequence[T TestingT[T]](t T, tester ChainComponentsInterfaceTester[T], boundContract types.BoundContract) []any {
func createMixedEventTypeSequence[T TestingT[T]](t T, tester ChainComponentsInterfaceTester[T], cw types.ContractWriter, boundContract types.BoundContract) []any {
var expectedSequenceData []any

ts1 := CreateTestStruct[T](0, tester)
expectedSequenceData = append(expectedSequenceData, &ts1)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts1, boundContract, types.Unconfirmed)
ts2 := CreateTestStruct[T](1, tester)
expectedSequenceData = append(expectedSequenceData, &ts2)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts2, boundContract, types.Unconfirmed)

ds1 := SomeDynamicTopicEvent{Field: "1"}
expectedSequenceData = append(expectedSequenceData, &ds1)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEventWithDynamicTopic, ds1, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEventWithDynamicTopic, ds1, boundContract, types.Unconfirmed)

ts3 := CreateTestStruct[T](2, tester)
expectedSequenceData = append(expectedSequenceData, &ts3)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts3, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts3, boundContract, types.Unconfirmed)

ds2 := SomeDynamicTopicEvent{Field: "2"}
expectedSequenceData = append(expectedSequenceData, &ds2)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEventWithDynamicTopic, ds2, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEventWithDynamicTopic, ds2, boundContract, types.Unconfirmed)

ts4 := CreateTestStruct[T](3, tester)
expectedSequenceData = append(expectedSequenceData, &ts4)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts4, boundContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, cw, MethodTriggeringEvent, ts4, boundContract, types.Unconfirmed)

return expectedSequenceData
}
Expand Down

0 comments on commit 5bd6eb4

Please sign in to comment.