diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index f0594f98e0..023006f972 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -388,6 +388,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) { verbose, e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM e2etests.TestV2ERC20DepositName, // necessary to have assets to withdraw + e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts + e2etests.TestOperationAddLiquidityERC20Name, e2etests.TestV2ERC20DepositAndCallRevertName, e2etests.TestV2ERC20DepositAndCallRevertWithCallName, e2etests.TestV2ERC20WithdrawAndCallRevertName, diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 8e8d45d806..040ed545f0 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -134,10 +134,12 @@ const ( TestV2EVMToZEVMCallName = "v2_evm_to_zevm_call" /* - Special tests + Operational tests Not used to test functionalities but do various interactions with the netwoks */ - TestDeploy = "deploy" + TestDeploy = "deploy" + TestOperationAddLiquidityETHName = "add_liquidity_eth" + TestOperationAddLiquidityERC20Name = "add_liquidity_erc20" ) // AllE2ETests is an ordered list of all e2e tests @@ -594,6 +596,12 @@ var AllE2ETests = []runner.E2ETest{ []runner.ArgDefinition{}, TestCriticalAdminTransactions, ), + runner.NewE2ETest( + TestMigrateTSSName, + "migrate TSS funds", + []runner.ArgDefinition{}, + TestMigrateTSS, + ), /* V2 smart contract tests */ @@ -749,9 +757,21 @@ var AllE2ETests = []runner.E2ETest{ TestDeployContract, ), runner.NewE2ETest( - TestMigrateTSSName, - "migrate TSS funds", - []runner.ArgDefinition{}, - TestMigrateTSS, + TestOperationAddLiquidityETHName, + "add liquidity to the ZETA/ETH pool", + []runner.ArgDefinition{ + {Description: "amountZETA", DefaultValue: "50000000000000000000"}, + {Description: "amountETH", DefaultValue: "50000000000000000000"}, + }, + TestOperationAddLiquidityETH, + ), + runner.NewE2ETest( + TestOperationAddLiquidityERC20Name, + "add liquidity to the ZETA/ERC20 pool", + []runner.ArgDefinition{ + {Description: "amountZETA", DefaultValue: "50000000000000000000"}, + {Description: "amountERC20", DefaultValue: "50000000000000000000"}, + }, + TestOperationAddLiquidityERC20, ), } diff --git a/e2e/e2etests/test_operation_add_liquidity_erc20.go b/e2e/e2etests/test_operation_add_liquidity_erc20.go new file mode 100644 index 0000000000..0b39580e37 --- /dev/null +++ b/e2e/e2etests/test_operation_add_liquidity_erc20.go @@ -0,0 +1,22 @@ +package e2etests + +import ( + "math/big" + + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/zetacore/e2e/runner" +) + +// TestOperationAddLiquidityETH is an operational test to add liquidity in gas token +func TestOperationAddLiquidityETH(r *runner.E2ERunner, args []string) { + require.Len(r, args, 2) + + // #nosec G115 e2e - always in range + liqZETA := big.NewInt(int64(parseInt(r, args[0]))) + // #nosec G115 e2e - always in range + liqETH := big.NewInt(int64(parseInt(r, args[1]))) + + // perform the add liquidity + r.AddLiquidityETH(liqZETA, liqETH) +} diff --git a/e2e/e2etests/test_operation_add_liquidity_eth.go b/e2e/e2etests/test_operation_add_liquidity_eth.go index ef5c713a70..f7b5b251c8 100644 --- a/e2e/e2etests/test_operation_add_liquidity_eth.go +++ b/e2e/e2etests/test_operation_add_liquidity_eth.go @@ -1,6 +1,22 @@ package e2etests -// TestOperationAddLiquidityETH is an operational test to add liquidity in gas token -//func TestOperationAddLiquidityETH(r *runner.E2ERunner, args []string) { -// -//} +import ( + "math/big" + + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/zetacore/e2e/runner" +) + +// TestOperationAddLiquidityERC20 is an operational test to add liquidity in erc20 token +func TestOperationAddLiquidityERC20(r *runner.E2ERunner, args []string) { + require.Len(r, args, 2) + + // #nosec G115 e2e - always in range + liqZETA := big.NewInt(int64(parseInt(r, args[0]))) + // #nosec G115 e2e - always in range + liqERC20 := big.NewInt(int64(parseInt(r, args[1]))) + + // perform the add liquidity + r.AddLiquidityERC20(liqZETA, liqERC20) +} diff --git a/e2e/e2etests/test_v2_erc20_deposit.go b/e2e/e2etests/test_v2_erc20_deposit.go index 354586ee25..2dd83c6b3a 100644 --- a/e2e/e2etests/test_v2_erc20_deposit.go +++ b/e2e/e2etests/test_v2_erc20_deposit.go @@ -35,9 +35,4 @@ func TestV2ERC20Deposit(r *runner.E2ERunner, args []string) { newBalance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress()) require.NoError(r, err) require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance) - - // add liquidity, 50ZETA/50ETH and 50ZETA/50ERC20 - fifty := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(50)) - r.AddLiquidityETH(fifty, fifty) - r.AddLiquidityERC20(fifty, fifty) } diff --git a/e2e/e2etests/test_v2_evm_to_zevm_call.go b/e2e/e2etests/test_v2_evm_to_zevm_call.go index 3f8c58f958..44fce408d1 100644 --- a/e2e/e2etests/test_v2_evm_to_zevm_call.go +++ b/e2e/e2etests/test_v2_evm_to_zevm_call.go @@ -19,7 +19,11 @@ func TestV2EVMToZEVMCall(r *runner.E2ERunner, args []string) { r.AssertTestDAppZEVMCalled(false, payloadMessageZEVMCall, big.NewInt(0)) // perform the withdraw - tx := r.V2EVMToZEMVCall(r.TestDAppV2ZEVMAddr, []byte(payloadMessageZEVMCall), gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}) + tx := r.V2EVMToZEMVCall( + r.TestDAppV2ZEVMAddr, + []byte(payloadMessageZEVMCall), + gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, + ) // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)