From 1cafbd614b3b3003610887fbd0684f6a31ed6181 Mon Sep 17 00:00:00 2001 From: Silas Lenihan Date: Thu, 5 Dec 2024 18:57:42 -0500 Subject: [PATCH] Fixed flakes and added parallelization to ChainComponents tests --- .../relay/evm/chain_components_test.go | 38 ++++++++++++++----- .../chain_components_interface_tester.go | 1 - 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/core/services/relay/evm/chain_components_test.go b/core/services/relay/evm/chain_components_test.go index 2fcdad0184c..a983efd56df 100644 --- a/core/services/relay/evm/chain_components_test.go +++ b/core/services/relay/evm/chain_components_test.go @@ -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 { @@ -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() diff --git a/core/services/relay/evm/evmtesting/chain_components_interface_tester.go b/core/services/relay/evm/evmtesting/chain_components_interface_tester.go index 71bd94f0e9f..652982d48ea 100644 --- a/core/services/relay/evm/evmtesting/chain_components_interface_tester.go +++ b/core/services/relay/evm/evmtesting/chain_components_interface_tester.go @@ -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)