Skip to content

Commit b586f48

Browse files
authored
Add regular send at the end of each TC for fast transfer (#18365)
* Add regular send at the end of each TC for fast transfer * Use contract directly as helper is not thread safe
1 parent 0275851 commit b586f48

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

integration-tests/smoke/ccip/ccip_fast_transfer_test.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
chainselectors "github.com/smartcontractkit/chain-selectors"
2424

25+
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router"
2526
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_5_0/rmn_contract"
2627
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_5_1/token_pool"
2728
cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
@@ -89,7 +90,7 @@ type fastTransferE2ETestCase struct {
8990
var (
9091
initialFillerTokenAmountOnDest = big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(1000))
9192
initialUserTokenAmountOnSource = big.NewInt(200000)
92-
defaultEthAmount = big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(1000))
93+
defaultEthAmount = big.NewInt(0).Mul(big.NewInt(params.Ether), big.NewInt(10000))
9394
transferAmount = big.NewInt(100000)
9495
expectedFastTransferFee = big.NewInt(100)
9596
tokenDecimals = uint8(18)
@@ -1239,6 +1240,50 @@ func runFastTransferTestCase(t *testing.T, ctx *fastTransferTestContext, tc *fas
12391240
runAssertions(t, sourceToken, destinationToken, fillerAddress, tc.postRegularTransferFillerAssertions, "Post Regular Transfer Filler Assertions")
12401241
runAssertions(t, sourceToken, destinationToken, userAddress, tc.postRegularTransferUserAssertions, "Post Regular Transfer User Assertions")
12411242
runAssertions(t, sourceToken, destinationToken, destinationTokenPoolAddress, tc.postRegularTransferPoolAssertions, "Post Regular Transfer Pool Assertions")
1243+
1244+
if !tc.expectNoExecutionError {
1245+
ctx.env.Logger.Info("Sanity check regular token transfer (slow-path)")
1246+
// We want to ensure regular transfer works as expected
1247+
message := router.ClientEVM2AnyMessage{
1248+
Receiver: common.LeftPadBytes(userAddress.Bytes(), 32),
1249+
Data: []byte{},
1250+
TokenAmounts: []router.ClientEVMTokenAmount{
1251+
{
1252+
Token: sourceToken.Address(),
1253+
Amount: initialUserTokenAmountOnSource,
1254+
},
1255+
},
1256+
FeeToken: common.HexToAddress("0x0"),
1257+
ExtraArgs: nil,
1258+
}
1259+
userBalance, err := destinationToken.BalanceOf(nil, userAddress)
1260+
require.NoError(t, err)
1261+
// Top-up user account on source chain
1262+
fundAccountWithToken(t, ctx.SourceChain(), userAddress, sourceMinter, initialUserTokenAmountOnSource, ctx.sourceLock)
1263+
approveToken(t, ctx.SourceChain(), userTransactor(), sourceToken, ctx.sourceChainState.Router.Address(), ctx.sourceLock)
1264+
func() {
1265+
ctx.sendLock.Lock()
1266+
defer ctx.sendLock.Unlock()
1267+
seqNum, err = ctx.sequenceNumberRetriever(nil, ctx.DestinationChainSelector())
1268+
require.NoError(t, err)
1269+
router := onChainState.Chains[ctx.SourceChainSelector()].Router
1270+
fee, err := router.GetFee(&bind.CallOpts{Context: context.Background()}, ctx.DestinationChainSelector(), message)
1271+
require.NoError(t, err)
1272+
userTransac := userTransactor()
1273+
userTransac.Value = fee
1274+
tx, err := router.CcipSend(userTransac, ctx.DestinationChainSelector(), message)
1275+
require.NoError(t, err)
1276+
ctx.env.Logger.Infof("Sending regular transfer transaction: %s", tx.Hash().Hex())
1277+
_, err = ctx.SourceChain().Confirm(tx)
1278+
require.NoError(t, err)
1279+
}()
1280+
1281+
ctx.waitForExecution(t, seqNum)
1282+
finalBalance, err := destinationToken.BalanceOf(nil, userAddress)
1283+
require.NoError(t, err)
1284+
expectedBalance := new(big.Int).Add(userBalance, initialUserTokenAmountOnSource)
1285+
require.Equal(t, expectedBalance.String(), finalBalance.String(), "Final balance after regular transfer does not match expected value")
1286+
}
12421287
})
12431288
}
12441289

0 commit comments

Comments
 (0)