From 6d7b91d526efe975e9ebe6e534f2735524d62b97 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Fri, 8 Nov 2024 11:13:26 +0100 Subject: [PATCH] test(`e2e`): add amount args for ERC20 withdraw tests (#3113) * update test * set args * add missing test * fix test --- cmd/zetae2e/local/v2.go | 1 + e2e/e2etests/e2etests.go | 8 ++++++-- e2e/e2etests/test_v2_erc20_withdraw_and_call.go | 9 +++++---- .../test_v2_erc20_withdraw_and_call_no_message.go | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/zetae2e/local/v2.go b/cmd/zetae2e/local/v2.go index f4dac2a534..770d7201ef 100644 --- a/cmd/zetae2e/local/v2.go +++ b/cmd/zetae2e/local/v2.go @@ -39,6 +39,7 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner e2etests.TestV2ERC20WithdrawAndArbitraryCallName, e2etests.TestV2ERC20WithdrawAndCallName, e2etests.TestV2ERC20DepositAndCallNoMessageName, + e2etests.TestV2ERC20WithdrawAndCallNoMessageName, )) // Test revert cases for gas token workflow diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index c1c5d8b533..842abecbe4 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -964,13 +964,17 @@ var AllE2ETests = []runner.E2ETest{ runner.NewE2ETest( TestV2ERC20WithdrawAndCallName, "withdraw ERC20 from ZEVM and authenticated call a contract using V2 contract", - []runner.ArgDefinition{}, + []runner.ArgDefinition{ + {Description: "amount", DefaultValue: "1000"}, + }, TestV2ERC20WithdrawAndCall, ), runner.NewE2ETest( TestV2ERC20WithdrawAndCallNoMessageName, "withdraw ERC20 from ZEVM and authenticated call a contract using V2 contract with no message", - []runner.ArgDefinition{}, + []runner.ArgDefinition{ + {Description: "amount", DefaultValue: "1000"}, + }, TestV2ERC20WithdrawAndCallNoMessage, ), runner.NewE2ETest( diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go index fbc9e2ae7a..8d8f916576 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go @@ -12,16 +12,17 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) { +func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) { + require.Len(r, args, 1) + previousGasLimit := r.ZEVMAuth.GasLimit r.ZEVMAuth.GasLimit = 10000000 defer func() { r.ZEVMAuth.GasLimit = previousGasLimit }() - // called with fixed amount without arg since onCall implementation is for TestDappV2 is simple and generic - // without decoding the payload and amount handling for erc20, purpose of test is to verify correct sender and payload are used - amount := big.NewInt(10000) + amount, ok := big.NewInt(0).SetString(args[0], 10) + require.True(r, ok, "Invalid amount specified for TestV2ERC20WithdrawAndCall") payload := randomPayload(r) diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_call_no_message.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call_no_message.go index 50396ee58c..09d884f94a 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_call_no_message.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_call_no_message.go @@ -43,7 +43,7 @@ func TestV2ERC20WithdrawAndCallNoMessage(r *runner.E2ERunner, args []string) { // check called messageIndex, err := r.TestDAppV2EVM.GetNoMessageIndex(&bind.CallOpts{}, r.EVMAddress()) require.NoError(r, err) - r.AssertTestDAppEVMCalled(true, messageIndex, amount) + r.AssertTestDAppEVMCalled(true, messageIndex, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(