From 2b87979a74a469b97b1483643fd276be002fef92 Mon Sep 17 00:00:00 2001 From: lumtis Date: Tue, 29 Oct 2024 09:53:01 +0100 Subject: [PATCH 1/5] fix e2e --- cmd/zetae2e/config/contracts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zetae2e/config/contracts.go b/cmd/zetae2e/config/contracts.go index 0d554ef480..a3a1527a33 100644 --- a/cmd/zetae2e/config/contracts.go +++ b/cmd/zetae2e/config/contracts.go @@ -266,7 +266,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { if err != nil { return fmt.Errorf("invalid TestDAppV2Addr: %w", err) } - r.TestDAppV2ZEVM, err = testdappv2.NewTestDAppV2(r.TestDAppV2ZEVMAddr, r.EVMClient) + r.TestDAppV2ZEVM, err = testdappv2.NewTestDAppV2(r.TestDAppV2ZEVMAddr, r.ZEVMClient) if err != nil { return err } From 0ca4358f8fe6ce8e2e425f0aebe523cfa918b873 Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 30 Oct 2024 11:31:39 +0100 Subject: [PATCH 2/5] decrease gas limit --- e2e/runner/v2_zevm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/runner/v2_zevm.go b/e2e/runner/v2_zevm.go index 681696b195..636f0f9e28 100644 --- a/e2e/runner/v2_zevm.go +++ b/e2e/runner/v2_zevm.go @@ -9,7 +9,7 @@ import ( "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol" ) -var gasLimit = big.NewInt(1000000) +var gasLimit = big.NewInt(250000) // V2ETHWithdraw calls Withdraw of Gateway with gas token on ZEVM func (r *E2ERunner) V2ETHWithdraw( From e26d65644f5679fa71a20f9e8dffffd9820015c9 Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 30 Oct 2024 11:37:33 +0100 Subject: [PATCH 3/5] use random payload --- e2e/e2etests/helpers.go | 11 +++++++++++ e2e/e2etests/test_v2_erc20_deposit_and_call.go | 10 +++++----- ...test_v2_erc20_deposit_and_call_revert_with_call.go | 10 +++++----- e2e/e2etests/test_v2_erc20_withdraw_and_call.go | 10 +++++----- ...est_v2_erc20_withdraw_and_call_revert_with_call.go | 10 +++++----- e2e/e2etests/test_v2_eth_deposit_and_call.go | 10 +++++----- .../test_v2_eth_deposit_and_call_revert_with_call.go | 10 +++++----- e2e/e2etests/test_v2_eth_withdraw_and_call.go | 10 +++++----- .../test_v2_eth_withdraw_and_call_revert_with_call.go | 10 +++++----- e2e/e2etests/test_v2_evm_to_zevm_call.go | 10 +++++----- e2e/e2etests/test_v2_zevm_to_evm_call.go | 10 +++++----- 11 files changed, 61 insertions(+), 50 deletions(-) diff --git a/e2e/e2etests/helpers.go b/e2e/e2etests/helpers.go index 8146ff52b8..3ee125b655 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" @@ -16,6 +18,15 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/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 b6529840ec..6894f0310d 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/zetacore/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 790434f58c..5e85784c20 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 @@ -11,8 +11,6 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/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) @@ -21,13 +19,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), }) @@ -37,5 +37,5 @@ 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)) } diff --git a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go index 609d74a8b9..f12446d7cf 100644 --- a/e2e/e2etests/test_v2_erc20_withdraw_and_call.go +++ b/e2e/e2etests/test_v2_erc20_withdraw_and_call.go @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const payloadMessageWithdrawERC20 = "this is a test ERC20 withdraw and call payload" - func TestV2ERC20WithdrawAndCall(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 TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) { tx := r.V2ERC20WithdrawAndCall( 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 TestV2ERC20WithdrawAndCall(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_revert_with_call.go b/e2e/e2etests/test_v2_erc20_withdraw_and_call_revert_with_call.go index 3d34bea2f7..247b48aae6 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 @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/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) @@ -32,7 +32,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), }, ) @@ -42,5 +42,5 @@ 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)) } diff --git a/e2e/e2etests/test_v2_eth_deposit_and_call.go b/e2e/e2etests/test_v2_eth_deposit_and_call.go index 657d3068f7..ffcc71c699 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/zetacore/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 ad23989e38..43747c9e6e 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 @@ -11,8 +11,6 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/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) @@ -21,13 +19,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), }) @@ -37,5 +37,5 @@ 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)) } diff --git a/e2e/e2etests/test_v2_eth_withdraw_and_call.go b/e2e/e2etests/test_v2_eth_withdraw_and_call.go index 5a54092288..9f29ff8b40 100644 --- a/e2e/e2etests/test_v2_eth_withdraw_and_call.go +++ b/e2e/e2etests/test_v2_eth_withdraw_and_call.go @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const payloadMessageWithdrawETH = "this is a test ETH withdraw and call payload" - func TestV2ETHWithdrawAndCall(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 TestV2ETHWithdrawAndCall(r *runner.E2ERunner, args []string) { tx := r.V2ETHWithdrawAndCall( r.TestDAppV2EVMAddr, amount, - r.EncodeGasCall(payloadMessageWithdrawETH), + r.EncodeGasCall(payload), gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, ) @@ -36,5 +36,5 @@ func TestV2ETHWithdrawAndCall(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_revert_with_call.go b/e2e/e2etests/test_v2_eth_withdraw_and_call_revert_with_call.go index 638e50a39c..f27bb9bb87 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 @@ -11,15 +11,15 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/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) @@ -31,7 +31,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), }, ) @@ -41,5 +41,5 @@ 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)) } diff --git a/e2e/e2etests/test_v2_evm_to_zevm_call.go b/e2e/e2etests/test_v2_evm_to_zevm_call.go index 44fce408d1..364b8b8cce 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/zetacore/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_call.go b/e2e/e2etests/test_v2_zevm_to_evm_call.go index 9132e72837..b68320759c 100644 --- a/e2e/e2etests/test_v2_zevm_to_evm_call.go +++ b/e2e/e2etests/test_v2_zevm_to_evm_call.go @@ -11,18 +11,18 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const payloadMessageEVMCall = "this is a test EVM call payload" - func TestV2ZEVMToEVMCall(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) // perform the withdraw - tx := r.V2ZEVMToEMVCall(r.TestDAppV2EVMAddr, r.EncodeSimpleCall(payloadMessageEVMCall), gatewayzevm.RevertOptions{ + tx := r.V2ZEVMToEMVCall(r.TestDAppV2EVMAddr, r.EncodeSimpleCall(payload), gatewayzevm.RevertOptions{ OnRevertGasLimit: big.NewInt(0), }) @@ -32,5 +32,5 @@ 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, payloadMessageEVMCall, big.NewInt(0)) + r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0)) } From 143a0abd41ffdcae01a590ea79a8c8843f22285f Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 30 Oct 2024 14:16:53 +0100 Subject: [PATCH 4/5] allow test with no args --- cmd/zetae2e/run.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index 9c36d8e3d2..a8eedad29b 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -136,20 +136,21 @@ 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{} + var tests []runner.E2ETestRunConfig 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, From 8163c3e916405a5312a4e92984e6bb89b4eb262a Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 30 Oct 2024 14:30:21 +0100 Subject: [PATCH 5/5] fix lint --- cmd/zetae2e/run.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index a8eedad29b..a688f48cf2 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -136,7 +136,8 @@ 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) { - var tests []runner.E2ETestRunConfig + tests := make([]runner.E2ETestRunConfig, 0, len(args)) + for _, arg := range args { parts := strings.SplitN(arg, ":", 2) testName := parts[0]