Skip to content

Commit

Permalink
ccip_messaging_test: Make messagingTestCase receiver chain agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jan 21, 2025
1 parent 3885e91 commit d32bac5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions integration-tests/smoke/ccip/ccip_messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,28 @@ func Test_CCIPMessaging(t *testing.T) {
)

t.Run("data message to eoa", func(t *testing.T) {
receiver := common.HexToAddress("0xdead")
out = runMessagingTestCase(messagingTestCase{
testCaseSetup: setup,
replayed: replayed,
nonce: nonce,
},
common.HexToAddress("0xdead"),
receiver[:],
[]byte("hello eoa"),
nil, // default extraArgs
testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call an EOA
)
})

t.Run("message to contract not implementing CCIPReceiver", func(t *testing.T) {
receiver := state.Chains[destChain].FeeQuoter.Address()
out = runMessagingTestCase(
messagingTestCase{
testCaseSetup: setup,
replayed: out.replayed,
nonce: out.nonce,
},
state.Chains[destChain].FeeQuoter.Address(),
receiver[:],
[]byte("hello FeeQuoter"),
nil, // default extraArgs
testhelpers.EXECUTION_STATE_SUCCESS, // success because offRamp won't call a contract not implementing CCIPReceiver
Expand All @@ -111,13 +113,14 @@ func Test_CCIPMessaging(t *testing.T) {
t.Run("message to contract implementing CCIPReceiver", func(t *testing.T) {
latestHead, err := e.Env.Chains[destChain].Client.HeaderByNumber(ctx, nil)
require.NoError(t, err)
receiver := state.Chains[destChain].Receiver.Address()
out = runMessagingTestCase(
messagingTestCase{
testCaseSetup: setup,
replayed: out.replayed,
nonce: out.nonce,
},
state.Chains[destChain].Receiver.Address(),
receiver[:],
[]byte("hello CCIPReceiver"),
nil, // default extraArgs
testhelpers.EXECUTION_STATE_SUCCESS,
Expand All @@ -136,13 +139,14 @@ func Test_CCIPMessaging(t *testing.T) {
t.Run("message to contract implementing CCIPReceiver with low exec gas", func(t *testing.T) {
latestHead, err := e.Env.Chains[destChain].Client.HeaderByNumber(ctx, nil)
require.NoError(t, err)
receiver := state.Chains[destChain].Receiver.Address()
out = runMessagingTestCase(
messagingTestCase{
testCaseSetup: setup,
replayed: out.replayed,
nonce: out.nonce,
},
state.Chains[destChain].Receiver.Address(),
receiver[:],
[]byte("hello CCIPReceiver with low exec gas"),
testhelpers.MakeEVMExtraArgsV2(1, false), // 1 gas is too low.
testhelpers.EXECUTION_STATE_FAILURE, // state would be failed onchain due to low gas
Expand Down Expand Up @@ -296,7 +300,7 @@ func sleepAndReplay(t *testing.T, e testhelpers.DeployedEnv, sourceChain, destCh

func runMessagingTestCase(
tc messagingTestCase,
receiver common.Address,
receiver []byte,
msgData []byte,
extraArgs []byte,
expectedExecutionState int,
Expand All @@ -308,10 +312,11 @@ func runMessagingTestCase(
}, tc.sourceChain, tc.sender)
require.NoError(tc.t, err)
require.Equal(tc.t, tc.nonce, latestNonce)
require.LessOrEqual(tc.t, 32, receiver)

startBlocks := make(map[uint64]*uint64)
msgSentEvent := testhelpers.TestSendRequest(tc.t, tc.deployedEnv.Env, tc.onchainState, tc.sourceChain, tc.destChain, false, router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(receiver.Bytes(), 32),
Receiver: common.LeftPadBytes(receiver, 32),
Data: msgData,
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
Expand Down

0 comments on commit d32bac5

Please sign in to comment.