Skip to content

Commit 422e6c1

Browse files
committed
fix(CORE-2383): use require over assert and fix simulated backend deprecation in ccipevm tests
- Replace assert with require before slice access in executecodec_test to avoid panics on failure - Increase simulated backend EVM timeout from 5s to 60s in msghasher_test - Replace deprecated backends.NewSimulatedBackend with simulated.NewBackend in both test files
1 parent cfca477 commit 422e6c1

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

core/capabilities/ccip/ccipevm/executecodec_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1111
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
1212
"github.com/ethereum/go-ethereum/common"
13-
"github.com/ethereum/go-ethereum/core"
13+
"github.com/ethereum/go-ethereum/core/types"
14+
"github.com/ethereum/go-ethereum/ethclient/simulated"
1415
chainsel "github.com/smartcontractkit/chain-selectors"
1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/mock"
@@ -173,9 +174,10 @@ func TestExecutePluginCodecV1(t *testing.T) {
173174

174175
// Deploy the contract
175176
transactor := evmtestutils.MustNewSimTransactor(t)
176-
simulatedBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
177+
b := simulated.NewBackend(types.GenesisAlloc{
177178
transactor.From: {Balance: assets.Ether(1000).ToInt()},
178-
}, 30e6)
179+
}, simulated.WithBlockGasLimit(30e6))
180+
simulatedBackend := &backends.SimulatedBackend{Backend: b, Client: b.Client()}
179181
address, _, _, err := report_codec.DeployReportCodec(transactor, simulatedBackend)
180182
require.NoError(t, err)
181183
simulatedBackend.Commit()
@@ -213,8 +215,8 @@ func TestExecutePluginCodecV1(t *testing.T) {
213215

214216
// decode using the contract
215217
contractDecodedReport, err := contract.DecodeExecuteReport(&bind.CallOpts{Context: ctx}, bytes)
216-
assert.NoError(t, err)
217-
assert.Len(t, contractDecodedReport, len(report.ChainReports))
218+
require.NoError(t, err)
219+
require.Len(t, contractDecodedReport, len(report.ChainReports))
218220
for i, expReport := range report.ChainReports {
219221
actReport := contractDecodedReport[i]
220222
assert.Equal(t, expReport.OffchainTokenData, actReport.OffchainTokenData)

core/capabilities/ccip/ccipevm/msghasher_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ import (
1414
"strings"
1515
"testing"
1616

17+
"time"
18+
1719
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1820
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
1921
"github.com/ethereum/go-ethereum/common"
2022
"github.com/ethereum/go-ethereum/common/hexutil"
21-
"github.com/ethereum/go-ethereum/core"
2223
"github.com/ethereum/go-ethereum/core/types"
24+
"github.com/ethereum/go-ethereum/eth/ethconfig"
25+
"github.com/ethereum/go-ethereum/ethclient/simulated"
26+
"github.com/ethereum/go-ethereum/node"
2327
agbinary "github.com/gagliardetto/binary"
2428
solanago "github.com/gagliardetto/solana-go"
2529
chainsel "github.com/smartcontractkit/chain-selectors"
@@ -199,9 +203,12 @@ type testSetupData struct {
199203

200204
func testSetup(t *testing.T) *testSetupData {
201205
transactor := evmtestutils.MustNewSimTransactor(t)
202-
simulatedBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
206+
b := simulated.NewBackend(types.GenesisAlloc{
203207
transactor.From: {Balance: assets.Ether(1000).ToInt()},
204-
}, 30e6)
208+
}, simulated.WithBlockGasLimit(30e6), func(_ *node.Config, ethCfg *ethconfig.Config) {
209+
ethCfg.RPCEVMTimeout = 60 * time.Second
210+
})
211+
simulatedBackend := &backends.SimulatedBackend{Backend: b, Client: b.Client()}
205212

206213
// Deploy the contract
207214
address, _, _, err := message_hasher.DeployMessageHasher(transactor, simulatedBackend)

0 commit comments

Comments
 (0)