Skip to content

Commit

Permalink
individual test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv committed Dec 2, 2024
1 parent 7ff44e2 commit b569433
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions integration-tests/smoke/ccip/ccip_message_limitations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,52 @@ func Test_CCIPMessageLimitations(t *testing.T) {
expRevert bool
}{
{
name: "hit limit on maxDataBytes, tokens, gasLimit should succeed",
name: "hit limit on data",
fromChain: chains[0],
toChain: chains[1],
msg: router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(onChainState.Chains[chains[1]].Receiver.Address().Bytes(), 32),
Data: []byte(strings.Repeat("0", int(chain0DestConfig.MaxDataBytes))),
FeeToken: common.HexToAddress("0x0"),
},
},
{
name: "hit limit on tokens",
fromChain: chains[0],
toChain: chains[1],
msg: router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(onChainState.Chains[chains[1]].Receiver.Address().Bytes(), 32),
TokenAmounts: slices.Repeat([]router.ClientEVMTokenAmount{
{Token: srcToken.Address(), Amount: big.NewInt(1)},
}, int(chain0DestConfig.MaxNumberOfTokensPerMsg)),
FeeToken: common.HexToAddress("0x0"),
},
},
{
name: "hit limit on gas limit",
fromChain: chains[0],
toChain: chains[1],
msg: router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(onChainState.Chains[chains[1]].Receiver.Address().Bytes(), 32),
Data: []byte(strings.Repeat("0", int(chain0DestConfig.MaxDataBytes))),
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: changeset.MakeEVMExtraArgsV2(uint64(chain0DestConfig.MaxPerMsgGasLimit), true),
},
},
//{ // TODO: exec plugin never executed this message.
// name: "hit limit on maxDataBytes, tokens, gasLimit should succeed",
// fromChain: chains[0],
// toChain: chains[1],
// msg: router.ClientEVM2AnyMessage{
// Receiver: common.LeftPadBytes(onChainState.Chains[chains[1]].Receiver.Address().Bytes(), 32),
// Data: []byte(strings.Repeat("0", int(chain0DestConfig.MaxDataBytes))),
// TokenAmounts: slices.Repeat([]router.ClientEVMTokenAmount{
// {Token: srcToken.Address(), Amount: big.NewInt(1)},
// }, int(chain0DestConfig.MaxNumberOfTokensPerMsg)),
// FeeToken: common.HexToAddress("0x0"),
// ExtraArgs: changeset.MakeEVMExtraArgsV2(uint64(chain0DestConfig.MaxPerMsgGasLimit), true),
// },
//},
{
name: "exceeding maxDataBytes",
fromChain: chains[0],
Expand Down Expand Up @@ -116,18 +149,22 @@ func Test_CCIPMessageLimitations(t *testing.T) {
expectedSeqNum := make(map[changeset.SourceDestPair]uint64)
expectedSeqNumExec := make(map[changeset.SourceDestPair][]uint64)
for _, msg := range testMsgs {
t.Logf("Sending msg: %s", msg.name)
require.NotEqual(t, msg.fromChain, msg.toChain, "fromChain and toChain cannot be the same")
startBlocks[msg.toChain] = nil
msgSentEvent, err := changeset.DoSendRequest(
t, testEnv.Env, onChainState, msg.fromChain, msg.toChain, false, msg.msg)

if msg.expRevert {
t.Logf("Message reverted as expected")
require.Error(t, err)
require.Contains(t, err.Error(), "execution reverted")
continue
}
require.NoError(t, err)

t.Logf("Message not reverted as expected")

expectedSeqNum[changeset.SourceDestPair{
SourceChainSelector: msg.fromChain,
DestChainSelector: msg.toChain,
Expand All @@ -141,16 +178,6 @@ func Test_CCIPMessageLimitations(t *testing.T) {

// Wait for all commit reports to land.
changeset.ConfirmCommitForAllWithExpectedSeqNums(t, testEnv.Env, onChainState, expectedSeqNum, startBlocks)

// After commit is reported on all chains, token prices should be updated in FeeQuoter.
for dest := range testEnv.Env.Chains {
linkAddress := onChainState.Chains[dest].LinkToken.Address()
feeQuoter := onChainState.Chains[dest].FeeQuoter
timestampedPrice, err := feeQuoter.GetTokenPrice(nil, linkAddress)
require.NoError(t, err)
require.Equal(t, changeset.MockLinkPrice, timestampedPrice.Value)
}

// Wait for all exec reports to land
changeset.ConfirmExecWithSeqNrsForAll(t, testEnv.Env, onChainState, expectedSeqNumExec, startBlocks)
}

0 comments on commit b569433

Please sign in to comment.