Skip to content

Commit

Permalink
Fixed flakes and added parallelization to ChainComponents tests
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Dec 5, 2024
1 parent d2cb377 commit 1cafbd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
38 changes: 29 additions & 9 deletions core/services/relay/evm/chain_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,36 @@ func TestContractReaderEventsInitValidation(t *testing.T) {
}

func TestChainComponents(t *testing.T) {
t.Parallel()
it := &EVMChainComponentsInterfaceTester[*testing.T]{Helper: &helper{}}
// TODO, generated binding tests are broken
it.DisableTests([]string{interfacetests.ContractReaderGetLatestValue})
it.Init(t)

// add new subtests here so that it can be run on real chains too
RunChainComponentsEvmTests(t, it)
RunChainComponentsInLoopEvmTests[*testing.T](t, commontestutils.WrapContractReaderTesterForLoop(it))
RunChainComponentsInLoopEvmTests(t, WrapContractReaderTesterWithBindings(t, it))
t.Run("RunChainComponentsEvmTests", func(t *testing.T) {
t.Parallel()
helper := &helper{}
// shared helper for separate parallel testers
it := &EVMChainComponentsInterfaceTester[*testing.T]{Helper: helper}
it.Init(t)
RunChainComponentsEvmTests(t, it)
})

t.Run("RunChainComponentsInLoopEvmTests", func(t *testing.T) {
t.Parallel()
helper := &helper{}
// shared helper for separate parallel testers
it := &EVMChainComponentsInterfaceTester[*testing.T]{Helper: helper}
it.Init(t)
RunChainComponentsInLoopEvmTests[*testing.T](t, commontestutils.WrapContractReaderTesterForLoop(it))
})

t.Run("RunChainComponentsInLoopEvmTestsWithBindings", func(t *testing.T) {
t.Parallel()
helper := &helper{}
// shared helper for separate parallel testers
helper.Init(t)
it := &EVMChainComponentsInterfaceTester[*testing.T]{Helper: helper}
// TODO, generated binding tests are broken
it.DisableTests([]string{interfacetests.ContractReaderGetLatestValue})
RunChainComponentsInLoopEvmTests(t, WrapContractReaderTesterWithBindings(t, it))
})
}

type helper struct {
Expand Down Expand Up @@ -277,7 +297,7 @@ func (h *helper) Backend() bind.ContractBackend {
if h.sim == nil {
h.sim = simulated.NewBackend(
evmtypes.GenesisAlloc{h.accounts[0].From: {Balance: big.NewInt(math.MaxInt64)}, h.accounts[1].From: {Balance: big.NewInt(math.MaxInt64)}}, simulated.WithBlockGasLimit(commonGasLimitOnEvms*5000))
cltest.Mine(h.sim, 1*time.Second)
cltest.Mine(h.sim, 500*time.Millisecond)
}

return h.sim.Client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ func (it *EVMChainComponentsInterfaceTester[T]) deployNewContract(t T) (string,

address, tx, ts, err := chain_reader_tester.DeployChainReaderTester(it.GetAuthWithGasSet(t), it.Helper.Backend())
require.NoError(t, err)
it.Helper.Commit()

it.IncNonce()
it.AwaitTx(t, tx)
Expand Down

0 comments on commit 1cafbd6

Please sign in to comment.