Skip to content

Commit

Permalink
PTT test cases added to the token transfer scenario (#15486)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara authored Dec 3, 2024
1 parent 86d5f99 commit 8971282
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ func TransferAndWaitForSuccess(
receiver common.Address,
data []byte,
expectedStatus int,
extraArgs []byte,
) {
identifier := SourceDestPair{
SourceChainSelector: sourceChain,
Expand All @@ -1127,7 +1128,7 @@ func TransferAndWaitForSuccess(
Data: data,
TokenAmounts: tokens,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
ExtraArgs: extraArgs,
})
expectedSeqNum[identifier] = msgSentEvent.SequenceNumber
expectedSeqNumExec[identifier] = []uint64{msgSentEvent.SequenceNumber}
Expand Down
50 changes: 49 additions & 1 deletion integration-tests/smoke/ccip/ccip_token_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestTokenTransfer(t *testing.T) {
tokenAmounts []router.ClientEVMTokenAmount
receiver common.Address
data []byte
extraData []byte
expectedTokenBalances map[common.Address]*big.Int
expectedExecutionState int
}{
Expand Down Expand Up @@ -156,13 +157,59 @@ func TestTokenTransfer(t *testing.T) {
Amount: oneE18,
},
},
receiver: state.Chains[sourceChain].Receiver.Address(),
receiver: state.Chains[sourceChain].Receiver.Address(),
extraData: changeset.MakeEVMExtraArgsV2(300_000, false),
expectedTokenBalances: map[common.Address]*big.Int{
selfServeSrcToken.Address(): new(big.Int).Add(oneE18, oneE18),
srcToken.Address(): oneE18,
},
expectedExecutionState: changeset.EXECUTION_STATE_SUCCESS,
},
{
name: "Sending token transfer with custom gasLimits to the EOA is successful",
srcChain: destChain,
dstChain: sourceChain,
tokenAmounts: []router.ClientEVMTokenAmount{
{
Token: selfServeDestToken.Address(),
Amount: oneE18,
},
{
Token: destToken.Address(),
Amount: new(big.Int).Add(oneE18, oneE18),
},
},
receiver: utils.RandomAddress(),
extraData: changeset.MakeEVMExtraArgsV2(1, false),
expectedTokenBalances: map[common.Address]*big.Int{
selfServeSrcToken.Address(): oneE18,
srcToken.Address(): new(big.Int).Add(oneE18, oneE18),
},
expectedExecutionState: changeset.EXECUTION_STATE_SUCCESS,
},
{
name: "Sending PTT with too low gas limit leads to the revert when receiver is a contract",
srcChain: destChain,
dstChain: sourceChain,
tokenAmounts: []router.ClientEVMTokenAmount{
{
Token: selfServeDestToken.Address(),
Amount: oneE18,
},
{
Token: destToken.Address(),
Amount: oneE18,
},
},
receiver: state.Chains[sourceChain].Receiver.Address(),
data: []byte("this should be reverted because gasLimit is too low, no tokens are transferred as well"),
extraData: changeset.MakeEVMExtraArgsV2(1, false),
expectedTokenBalances: map[common.Address]*big.Int{
selfServeSrcToken.Address(): big.NewInt(0),
srcToken.Address(): big.NewInt(0),
},
expectedExecutionState: changeset.EXECUTION_STATE_FAILURE,
},
}

for _, tt := range tcs {
Expand All @@ -184,6 +231,7 @@ func TestTokenTransfer(t *testing.T) {
tt.receiver,
tt.data,
tt.expectedExecutionState,
tt.extraData,
)

for token, balance := range tt.expectedTokenBalances {
Expand Down
1 change: 1 addition & 0 deletions integration-tests/smoke/ccip/ccip_usdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func TestUSDCTokenTransfer(t *testing.T) {
tt.receiver,
tt.data,
tt.expectedExecutionState,
nil,
)

for token, balance := range tt.expectedTokenBalances {
Expand Down

0 comments on commit 8971282

Please sign in to comment.