From 6ef5c57d6d3ca6a0ce813d35cf86a9483fffde23 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 30 Oct 2024 15:50:07 +0100 Subject: [PATCH] test(`e2e`): improve E2E reliability for tests on live network (#3061) * test(e2e): reduce gas limit used for withdraw and call * try 200k * 250k * use random string for payloads * fix lint * renaming * allow test with no args * fix lint --- cmd/zetae2e/run.go | 20 ++++++++++--------- e2e/e2etests/helpers.go | 11 ++++++++++ .../test_v2_erc20_deposit_and_call.go | 10 +++++----- ...erc20_deposit_and_call_revert_with_call.go | 12 +++++------ ...st_v2_erc20_withdraw_and_arbitrary_call.go | 10 +++++----- .../test_v2_erc20_withdraw_and_call.go | 12 +++++------ ...rc20_withdraw_and_call_revert_with_call.go | 12 +++++------ e2e/e2etests/test_v2_eth_deposit_and_call.go | 10 +++++----- ...2_eth_deposit_and_call_revert_with_call.go | 12 +++++------ ...test_v2_eth_withdraw_and_arbitrary_call.go | 10 +++++----- e2e/e2etests/test_v2_eth_withdraw_and_call.go | 12 +++++------ ..._eth_withdraw_and_call_revert_with_call.go | 12 +++++------ ..._eth_withdraw_and_call_through_contract.go | 10 +++++----- e2e/e2etests/test_v2_evm_to_zevm_call.go | 10 +++++----- .../test_v2_zevm_to_evm_arbitrary_call.go | 10 +++++----- e2e/e2etests/test_v2_zevm_to_evm_call.go | 12 +++++------ ...st_v2_zevm_to_evm_call_through_contract.go | 12 +++++------ e2e/runner/v2_zevm.go | 4 ++-- 18 files changed, 107 insertions(+), 94 deletions(-) diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index f58e5b51cf..fe52f056d5 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -155,20 +155,22 @@ func runE2ETest(cmd *cobra.Command, args []string) error { // parseCmdArgsToE2ETestRunConfig parses command-line arguments into a slice of E2ETestRunConfig structs. func parseCmdArgsToE2ETestRunConfig(args []string) ([]runner.E2ETestRunConfig, error) { - tests := []runner.E2ETestRunConfig{} + tests := make([]runner.E2ETestRunConfig, 0, len(args)) + for _, arg := range args { parts := strings.SplitN(arg, ":", 2) - if len(parts) != 2 { - return nil, errors.New("command arguments should be in format: testName:testArgs") - } - if parts[0] == "" { + testName := parts[0] + if testName == "" { return nil, errors.New("missing testName") } - testName := parts[0] - testArgs := []string{} - if parts[1] != "" { - testArgs = strings.Split(parts[1], ",") + + var testArgs []string + if len(parts) > 1 { + if parts[1] != "" { + testArgs = strings.Split(parts[1], ",") + } } + tests = append(tests, runner.E2ETestRunConfig{ Name: testName, Args: testArgs, diff --git a/e2e/e2etests/helpers.go b/e2e/e2etests/helpers.go index 64f0920c2a..a7a997d70b 100644 --- a/e2e/e2etests/helpers.go +++ b/e2e/e2etests/helpers.go @@ -1,6 +1,8 @@ package e2etests import ( + "crypto/rand" + "encoding/hex" "math/big" "strconv" @@ -20,6 +22,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) +// randomPayload generates a random payload to be used in gateway calls for testing purposes +func randomPayload(r *runner.E2ERunner) string { + bytes := make([]byte, 50) + _, err := rand.Read(bytes) + require.NoError(r, err) + + return hex.EncodeToString(bytes) +} + func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) *btcjson.TxRawResult { tx, err := r.BTCZRC20.Approve( r.ZEVMAuth, diff --git a/e2e/e2etests/test_v2_erc20_deposit_and_call.go b/e2e/e2etests/test_v2_erc20_deposit_and_call.go index 332f2d6009..7b8215162a 100644 --- a/e2e/e2etests/test_v2_erc20_deposit_and_call.go +++ b/e2e/e2etests/test_v2_erc20_deposit_and_call.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageDepositERC20 = "this is a test ERC20 deposit and call payload" - func TestV2ERC20DepositAndCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) @@ -22,7 +20,9 @@ func TestV2ERC20DepositAndCall(r *runner.E2ERunner, args []string) { r.ApproveERC20OnEVM(r.GatewayEVMAddr) - r.AssertTestDAppZEVMCalled(false, payloadMessageDepositERC20, amount) + payload := randomPayload(r) + + r.AssertTestDAppZEVMCalled(false, payload, amount) oldBalance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{}, r.TestDAppV2ZEVMAddr) require.NoError(r, err) @@ -31,7 +31,7 @@ func TestV2ERC20DepositAndCall(r *runner.E2ERunner, args []string) { tx := r.V2ERC20DepositAndCall( r.TestDAppV2ZEVMAddr, amount, - []byte(payloadMessageDepositERC20), + []byte(payload), gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -41,7 +41,7 @@ func TestV2ERC20DepositAndCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppZEVMCalled(true, payloadMessageDepositERC20, amount) + r.AssertTestDAppZEVMCalled(true, payload, amount) // check the balance was updated newBalance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{}, r.TestDAppV2ZEVMAddr) diff --git a/e2e/e2etests/test_v2_erc20_deposit_and_call_revert_with_call.go b/e2e/e2etests/test_v2_erc20_deposit_and_call_revert_with_call.go index 0bee6ff837..7f52c9e70f 100644 --- a/e2e/e2etests/test_v2_erc20_deposit_and_call_revert_with_call.go +++ b/e2e/e2etests/test_v2_erc20_deposit_and_call_revert_with_call.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageDepositOnRevertERC20 = "this is a test ERC20 deposit and call on revert" - func TestV2ERC20DepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) @@ -22,13 +20,15 @@ func TestV2ERC20DepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) r.ApproveERC20OnEVM(r.GatewayEVMAddr) - r.AssertTestDAppEVMCalled(false, payloadMessageDepositOnRevertERC20, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) // perform the deposit tx := r.V2ERC20DepositAndCall(r.TestDAppV2ZEVMAddr, amount, []byte("revert"), gatewayevm.RevertOptions{ RevertAddress: r.TestDAppV2EVMAddr, CallOnRevert: true, - RevertMessage: []byte(payloadMessageDepositOnRevertERC20), + RevertMessage: []byte(payload), OnRevertGasLimit: big.NewInt(200000), }) @@ -38,12 +38,12 @@ func TestV2ERC20DepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppEVMCalled(true, payloadMessageDepositOnRevertERC20, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageDepositOnRevertERC20), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.EVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_arbitrary_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_arbitrary_call.go index ca48f4be8b..6a73774f18 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_arbitrary_call.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_arbitrary_call.go @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageWithdrawERC20 = "this is a test ERC20 withdraw and call payload" - func TestV2ERC20WithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ERC20WithdrawAndCall") - r.AssertTestDAppEVMCalled(false, payloadMessageWithdrawERC20, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) r.ApproveERC20ZRC20(r.GatewayZEVMAddr) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -28,7 +28,7 @@ func TestV2ERC20WithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { tx := r.V2ERC20WithdrawAndArbitraryCall( r.TestDAppV2EVMAddr, amount, - r.EncodeERC20Call(r.ERC20Addr, amount, payloadMessageWithdrawERC20), + r.EncodeERC20Call(r.ERC20Addr, amount, payload), gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -37,5 +37,5 @@ func TestV2ERC20WithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageWithdrawERC20, amount) + r.AssertTestDAppEVMCalled(true, payload, amount) } diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go index 4596ba12da..fbc9e2ae7a 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageWithdrawAuthenticatedCallERC20 = "this is a test ERC20 withdraw and authenticated call payload" - func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) { previousGasLimit := r.ZEVMAuth.GasLimit r.ZEVMAuth.GasLimit = 10000000 @@ -25,7 +23,9 @@ func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) { // 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) - r.AssertTestDAppEVMCalled(false, payloadMessageWithdrawAuthenticatedCallERC20, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) r.ApproveERC20ZRC20(r.GatewayZEVMAddr) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -34,7 +34,7 @@ func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) { tx := r.V2ERC20WithdrawAndCall( r.TestDAppV2EVMAddr, amount, - []byte(payloadMessageWithdrawAuthenticatedCallERC20), + []byte(payload), gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -43,12 +43,12 @@ func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, _ []string) { r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageWithdrawAuthenticatedCallERC20, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageWithdrawAuthenticatedCallERC20), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.ZEVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call_revert_with_call.go index fb3b3201ff..b3d331f296 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_call_revert_with_call.go @@ -12,15 +12,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageWithdrawOnRevertERC20 = "this is a test ERC20 withdraw and call on revert" - func TestV2ERC20WithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ERC20WithdrawAndCallRevertWithCall") - r.AssertTestDAppZEVMCalled(false, payloadMessageWithdrawOnRevertERC20, amount) + payload := randomPayload(r) + + r.AssertTestDAppZEVMCalled(false, payload, amount) r.ApproveERC20ZRC20(r.GatewayZEVMAddr) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -33,7 +33,7 @@ func TestV2ERC20WithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string gatewayzevm.RevertOptions{ RevertAddress: r.TestDAppV2ZEVMAddr, CallOnRevert: true, - RevertMessage: []byte(payloadMessageWithdrawOnRevertERC20), + RevertMessage: []byte(payload), OnRevertGasLimit: big.NewInt(0), }, ) @@ -43,12 +43,12 @@ func TestV2ERC20WithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctx.CctxStatus.Status) - r.AssertTestDAppZEVMCalled(true, payloadMessageWithdrawOnRevertERC20, big.NewInt(0)) + r.AssertTestDAppZEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2ZEVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageWithdrawOnRevertERC20), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.ZEVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_eth_deposit_and_call.go b/e2e/e2etests/test_v2_eth_deposit_and_call.go index a7b2a3a8be..67fbe73846 100644 --- a/e2e/e2etests/test_v2_eth_deposit_and_call.go +++ b/e2e/e2etests/test_v2_eth_deposit_and_call.go @@ -12,15 +12,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageDepositETH = "this is a test ETH deposit and call payload" - func TestV2ETHDepositAndCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ETHDepositAndCall") - r.AssertTestDAppZEVMCalled(false, payloadMessageDepositETH, amount) + payload := randomPayload(r) + + r.AssertTestDAppZEVMCalled(false, payload, amount) oldBalance, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.TestDAppV2ZEVMAddr) require.NoError(r, err) @@ -29,7 +29,7 @@ func TestV2ETHDepositAndCall(r *runner.E2ERunner, args []string) { tx := r.V2ETHDepositAndCall( r.TestDAppV2ZEVMAddr, amount, - []byte(payloadMessageDepositETH), + []byte(payload), gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -39,7 +39,7 @@ func TestV2ETHDepositAndCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppZEVMCalled(true, payloadMessageDepositETH, amount) + r.AssertTestDAppZEVMCalled(true, payload, amount) // check the balance was updated newBalance, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.TestDAppV2ZEVMAddr) diff --git a/e2e/e2etests/test_v2_eth_deposit_and_call_revert_with_call.go b/e2e/e2etests/test_v2_eth_deposit_and_call_revert_with_call.go index 245aa3e636..f01f2ce6e8 100644 --- a/e2e/e2etests/test_v2_eth_deposit_and_call_revert_with_call.go +++ b/e2e/e2etests/test_v2_eth_deposit_and_call_revert_with_call.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageDepositOnRevertETH = "this is a test ETH deposit and call on revert" - func TestV2ETHDepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) @@ -22,13 +20,15 @@ func TestV2ETHDepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) { r.ApproveERC20OnEVM(r.GatewayEVMAddr) - r.AssertTestDAppEVMCalled(false, payloadMessageDepositOnRevertETH, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) // perform the deposit tx := r.V2ETHDepositAndCall(r.TestDAppV2ZEVMAddr, amount, []byte("revert"), gatewayevm.RevertOptions{ RevertAddress: r.TestDAppV2EVMAddr, CallOnRevert: true, - RevertMessage: []byte(payloadMessageDepositOnRevertETH), + RevertMessage: []byte(payload), OnRevertGasLimit: big.NewInt(200000), }) @@ -38,12 +38,12 @@ func TestV2ETHDepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppEVMCalled(true, payloadMessageDepositOnRevertETH, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageDepositOnRevertETH), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.EVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_eth_withdraw_and_arbitrary_call.go b/e2e/e2etests/test_v2_eth_withdraw_and_arbitrary_call.go index b290e33fcb..c3bedecb02 100644 --- a/e2e/e2etests/test_v2_eth_withdraw_and_arbitrary_call.go +++ b/e2e/e2etests/test_v2_eth_withdraw_and_arbitrary_call.go @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageWithdrawETH = "this is a test ETH withdraw and call payload" - func TestV2ETHWithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ETHWithdrawAndCall") - r.AssertTestDAppEVMCalled(false, payloadMessageWithdrawETH, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -27,7 +27,7 @@ func TestV2ETHWithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { tx := r.V2ETHWithdrawAndArbitraryCall( r.TestDAppV2EVMAddr, amount, - r.EncodeGasCall(payloadMessageWithdrawETH), + r.EncodeGasCall(payload), gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -36,5 +36,5 @@ func TestV2ETHWithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) { r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageWithdrawETH, amount) + r.AssertTestDAppEVMCalled(true, payload, amount) } diff --git a/e2e/e2etests/test_v2_eth_withdraw_and_call.go b/e2e/e2etests/test_v2_eth_withdraw_and_call.go index bffd037e72..9962bfe462 100644 --- a/e2e/e2etests/test_v2_eth_withdraw_and_call.go +++ b/e2e/e2etests/test_v2_eth_withdraw_and_call.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageAuthenticatedWithdrawETH = "this is a test ETH withdraw and authenticated call payload" - func TestV2ETHWithdrawAndCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) @@ -26,7 +24,9 @@ func TestV2ETHWithdrawAndCall(r *runner.E2ERunner, args []string) { amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ETHWithdrawAndCall") - r.AssertTestDAppEVMCalled(false, payloadMessageAuthenticatedWithdrawETH, amount) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, amount) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -34,7 +34,7 @@ func TestV2ETHWithdrawAndCall(r *runner.E2ERunner, args []string) { tx := r.V2ETHWithdrawAndCall( r.TestDAppV2EVMAddr, amount, - []byte(payloadMessageAuthenticatedWithdrawETH), + []byte(payload), gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -43,12 +43,12 @@ func TestV2ETHWithdrawAndCall(r *runner.E2ERunner, args []string) { r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageAuthenticatedWithdrawETH, amount) + r.AssertTestDAppEVMCalled(true, payload, amount) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageAuthenticatedWithdrawETH), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.ZEVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_eth_withdraw_and_call_revert_with_call.go b/e2e/e2etests/test_v2_eth_withdraw_and_call_revert_with_call.go index f613ebffc2..8c7ea40f9e 100644 --- a/e2e/e2etests/test_v2_eth_withdraw_and_call_revert_with_call.go +++ b/e2e/e2etests/test_v2_eth_withdraw_and_call_revert_with_call.go @@ -12,15 +12,15 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageWithdrawOnRevertETH = "this is a test ETH withdraw and call on revert" - func TestV2ETHWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount, ok := big.NewInt(0).SetString(args[0], 10) require.True(r, ok, "Invalid amount specified for TestV2ETHWithdrawAndCallRevertWithCall") - r.AssertTestDAppZEVMCalled(false, payloadMessageWithdrawOnRevertETH, amount) + payload := randomPayload(r) + + r.AssertTestDAppZEVMCalled(false, payload, amount) r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -32,7 +32,7 @@ func TestV2ETHWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) gatewayzevm.RevertOptions{ RevertAddress: r.TestDAppV2ZEVMAddr, CallOnRevert: true, - RevertMessage: []byte(payloadMessageWithdrawOnRevertETH), + RevertMessage: []byte(payload), OnRevertGasLimit: big.NewInt(0), }, ) @@ -42,12 +42,12 @@ func TestV2ETHWithdrawAndCallRevertWithCall(r *runner.E2ERunner, args []string) r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_Reverted, cctx.CctxStatus.Status) - r.AssertTestDAppZEVMCalled(true, payloadMessageWithdrawOnRevertETH, big.NewInt(0)) + r.AssertTestDAppZEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2ZEVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageWithdrawOnRevertETH), + []byte(payload), ) require.NoError(r, err) require.Equal(r, r.ZEVMAuth.From, senderForMsg) diff --git a/e2e/e2etests/test_v2_eth_withdraw_and_call_through_contract.go b/e2e/e2etests/test_v2_eth_withdraw_and_call_through_contract.go index 28c36ee69d..ce82f95829 100644 --- a/e2e/e2etests/test_v2_eth_withdraw_and_call_through_contract.go +++ b/e2e/e2etests/test_v2_eth_withdraw_and_call_through_contract.go @@ -12,8 +12,6 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageAuthenticatedWithdrawETHThroughContract = "this is a test ETH withdraw and authenticated call payload through contract" - func TestV2ETHWithdrawAndCallThroughContract(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) @@ -40,10 +38,12 @@ func TestV2ETHWithdrawAndCallThroughContract(r *runner.E2ERunner, args []string) require.NoError(r, err) utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + payload := randomPayload(r) + // perform the authenticated call tx = r.V2ETHWithdrawAndCallThroughContract(gatewayCaller, r.TestDAppV2EVMAddr, amount, - []byte(payloadMessageAuthenticatedWithdrawETHThroughContract), + []byte(payload), gatewayzevmcaller.RevertOptions{OnRevertGasLimit: big.NewInt(0)}) utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) @@ -51,12 +51,12 @@ func TestV2ETHWithdrawAndCallThroughContract(r *runner.E2ERunner, args []string) r.Logger.CCTX(*cctx, "withdraw") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageAuthenticatedWithdrawETHThroughContract, amount) + r.AssertTestDAppEVMCalled(true, payload, amount) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageAuthenticatedWithdrawETHThroughContract), + []byte(payload), ) require.NoError(r, err) require.Equal(r, gatewayCallerAddr, senderForMsg) diff --git a/e2e/e2etests/test_v2_evm_to_zevm_call.go b/e2e/e2etests/test_v2_evm_to_zevm_call.go index 9fb5502e7a..305f279164 100644 --- a/e2e/e2etests/test_v2_evm_to_zevm_call.go +++ b/e2e/e2etests/test_v2_evm_to_zevm_call.go @@ -11,17 +11,17 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageZEVMCall = "this is a test ZEVM call payload" - func TestV2EVMToZEVMCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 0) - r.AssertTestDAppZEVMCalled(false, payloadMessageZEVMCall, big.NewInt(0)) + payload := randomPayload(r) + + r.AssertTestDAppZEVMCalled(false, payload, big.NewInt(0)) // perform the withdraw tx := r.V2EVMToZEMVCall( r.TestDAppV2ZEVMAddr, - []byte(payloadMessageZEVMCall), + []byte(payload), gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -31,5 +31,5 @@ func TestV2EVMToZEVMCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppZEVMCalled(true, payloadMessageZEVMCall, big.NewInt(0)) + r.AssertTestDAppZEVMCalled(true, payload, big.NewInt(0)) } diff --git a/e2e/e2etests/test_v2_zevm_to_evm_arbitrary_call.go b/e2e/e2etests/test_v2_zevm_to_evm_arbitrary_call.go index 4b722fc4ae..429fbea714 100644 --- a/e2e/e2etests/test_v2_zevm_to_evm_arbitrary_call.go +++ b/e2e/e2etests/test_v2_zevm_to_evm_arbitrary_call.go @@ -11,12 +11,12 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageEVMCall = "this is a test EVM call payload" - func TestV2ZEVMToEVMArbitraryCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 0) - r.AssertTestDAppEVMCalled(false, payloadMessageEVMCall, big.NewInt(0)) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, big.NewInt(0)) // Necessary approval for fee payment r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -24,7 +24,7 @@ func TestV2ZEVMToEVMArbitraryCall(r *runner.E2ERunner, args []string) { // perform the call tx := r.V2ZEVMToEMVArbitraryCall( r.TestDAppV2EVMAddr, - r.EncodeSimpleCall(payloadMessageEVMCall), + r.EncodeSimpleCall(payload), gatewayzevm.RevertOptions{ OnRevertGasLimit: big.NewInt(0), }, @@ -36,5 +36,5 @@ func TestV2ZEVMToEVMArbitraryCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppEVMCalled(true, payloadMessageEVMCall, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) } diff --git a/e2e/e2etests/test_v2_zevm_to_evm_call.go b/e2e/e2etests/test_v2_zevm_to_evm_call.go index 9641778e3c..2f1ed19d1b 100644 --- a/e2e/e2etests/test_v2_zevm_to_evm_call.go +++ b/e2e/e2etests/test_v2_zevm_to_evm_call.go @@ -12,12 +12,12 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageEVMAuthenticatedCall = "this is a test EVM authenticated call payload" - func TestV2ZEVMToEVMCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 0) - r.AssertTestDAppEVMCalled(false, payloadMessageEVMAuthenticatedCall, big.NewInt(0)) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, big.NewInt(0)) // necessary approval for fee payment r.ApproveETHZRC20(r.GatewayZEVMAddr) @@ -25,7 +25,7 @@ func TestV2ZEVMToEVMCall(r *runner.E2ERunner, args []string) { // perform the authenticated call tx := r.V2ZEVMToEMVCall( r.TestDAppV2EVMAddr, - []byte(payloadMessageEVMAuthenticatedCall), + []byte(payload), gatewayzevm.RevertOptions{ OnRevertGasLimit: big.NewInt(0), }, @@ -37,10 +37,10 @@ func TestV2ZEVMToEVMCall(r *runner.E2ERunner, args []string) { require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) // check the payload was received on the contract - r.AssertTestDAppEVMCalled(true, payloadMessageEVMAuthenticatedCall, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used - senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(&bind.CallOpts{}, []byte(payloadMessageEVMAuthenticatedCall)) + senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(&bind.CallOpts{}, []byte(payload)) require.NoError(r, err) require.Equal(r, r.ZEVMAuth.From, senderForMsg) } diff --git a/e2e/e2etests/test_v2_zevm_to_evm_call_through_contract.go b/e2e/e2etests/test_v2_zevm_to_evm_call_through_contract.go index 7ff9158365..fa54ca34f6 100644 --- a/e2e/e2etests/test_v2_zevm_to_evm_call_through_contract.go +++ b/e2e/e2etests/test_v2_zevm_to_evm_call_through_contract.go @@ -12,12 +12,12 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -const payloadMessageEVMAuthenticatedCallThroughContract = "this is a test EVM authenticated call payload through contract" - func TestV2ZEVMToEVMCallThroughContract(r *runner.E2ERunner, args []string) { require.Len(r, args, 0) - r.AssertTestDAppEVMCalled(false, payloadMessageEVMAuthenticatedCallThroughContract, big.NewInt(0)) + payload := randomPayload(r) + + r.AssertTestDAppEVMCalled(false, payload, big.NewInt(0)) // deploy caller contract and send it gas zrc20 to pay gas fee gatewayCallerAddr, tx, gatewayCaller, err := gatewayzevmcaller.DeployGatewayZEVMCaller( @@ -37,7 +37,7 @@ func TestV2ZEVMToEVMCallThroughContract(r *runner.E2ERunner, args []string) { tx = r.V2ZEVMToEMVCallThroughContract( gatewayCaller, r.TestDAppV2EVMAddr, - []byte(payloadMessageEVMAuthenticatedCallThroughContract), + []byte(payload), gatewayzevmcaller.RevertOptions{ OnRevertGasLimit: big.NewInt(0), }, @@ -47,12 +47,12 @@ func TestV2ZEVMToEVMCallThroughContract(r *runner.E2ERunner, args []string) { r.Logger.CCTX(*cctx, "call") require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - r.AssertTestDAppEVMCalled(true, payloadMessageEVMAuthenticatedCallThroughContract, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) // check expected sender was used senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage( &bind.CallOpts{}, - []byte(payloadMessageEVMAuthenticatedCallThroughContract), + []byte(payload), ) require.NoError(r, err) require.Equal(r, gatewayCallerAddr, senderForMsg) diff --git a/e2e/runner/v2_zevm.go b/e2e/runner/v2_zevm.go index 45dd8c6761..4f6f299db2 100644 --- a/e2e/runner/v2_zevm.go +++ b/e2e/runner/v2_zevm.go @@ -11,7 +11,7 @@ import ( gatewayzevmcaller "github.com/zeta-chain/node/pkg/contracts/gatewayzevmcaller" ) -var gasLimit = big.NewInt(1000000) +var gasLimit = big.NewInt(250000) // V2ETHWithdraw calls Withdraw of Gateway with gas token on ZEVM func (r *E2ERunner) V2ETHWithdraw( @@ -31,7 +31,7 @@ func (r *E2ERunner) V2ETHWithdraw( return tx } -// V2ETHWithdrawAndCall calls WithdrawAndCall of Gateway with gas token on ZEVM using arbitrary call +// V2ETHWithdrawAndArbitraryCall calls WithdrawAndCall of Gateway with gas token on ZEVM using arbitrary call func (r *E2ERunner) V2ETHWithdrawAndArbitraryCall( receiver ethcommon.Address, amount *big.Int,