From c511620f0bec34806a3b5d0f8218a73f252eee50 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 22 Nov 2024 14:49:57 +0100 Subject: [PATCH 1/5] increase erc20 values --- cmd/zetae2e/local/erc20.go | 2 +- e2e/runner/evm.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/zetae2e/local/erc20.go b/cmd/zetae2e/local/erc20.go index 3b2830a066..8c9ef06869 100644 --- a/cmd/zetae2e/local/erc20.go +++ b/cmd/zetae2e/local/erc20.go @@ -37,7 +37,7 @@ func erc20TestRoutine( startTime := time.Now() // funding the account - txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 10) + txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 10000) erc20Runner.WaitForTxReceiptOnEvm(txERC20Send) // depositing the necessary tokens on ZetaChain diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index 1fc18f1a5c..d12e895d96 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -60,7 +60,8 @@ func (r *E2ERunner) SendERC20OnEvm(address ethcommon.Address, amountERC20 int64) func (r *E2ERunner) DepositERC20() ethcommon.Hash { r.Logger.Print("⏳ depositing ERC20 into ZEVM") - return r.DepositERC20WithAmountAndMessage(r.EVMAddress(), big.NewInt(1e18), []byte{}) + oneHundred := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(100)) + return r.DepositERC20WithAmountAndMessage(r.EVMAddress(), oneHundred, []byte{}) } func (r *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, amount *big.Int, msg []byte) ethcommon.Hash { From 5f13764ceae81a0eaf311a12874507c37382b932 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 22 Nov 2024 14:50:18 +0100 Subject: [PATCH 2/5] consolidate function call --- e2e/e2etests/test_erc20_deposit_refund.go | 45 ++--------------------- e2e/runner/liquidity.go | 8 +++- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/e2e/e2etests/test_erc20_deposit_refund.go b/e2e/e2etests/test_erc20_deposit_refund.go index 816cf702a8..6823799c38 100644 --- a/e2e/e2etests/test_erc20_deposit_refund.go +++ b/e2e/e2etests/test_erc20_deposit_refund.go @@ -2,13 +2,10 @@ package e2etests import ( "errors" - "fmt" - "math/big" - "time" - "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" + "math/big" "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" @@ -64,7 +61,8 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { r.Logger.Info("Sending a deposit that should revert with a liquidity pool") r.Logger.Info("Creating the liquidity pool USTD/ZETA") - err = createZetaERC20LiquidityPool(r) + fifty := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(50)) + r.AddLiquidityERC20(fifty, fifty) require.NoError(r, err) r.Logger.Info("Liquidity pool created") @@ -120,43 +118,6 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { r.Logger.Info("\tbalance after refund: %s", erc20BalanceAfterRefund.String()) } -func createZetaERC20LiquidityPool(r *runner.E2ERunner) error { - amount := big.NewInt(1e10) - txHash := r.DepositERC20WithAmountAndMessage(r.EVMAddress(), amount, []byte{}) - utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - - tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e10)) - if err != nil { - return err - } - receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - if receipt.Status == 0 { - return errors.New("approve failed") - } - - previousValue := r.ZEVMAuth.Value - r.ZEVMAuth.Value = big.NewInt(1e10) - tx, err = r.UniswapV2Router.AddLiquidityETH( - r.ZEVMAuth, - r.ERC20ZRC20Addr, - amount, - big.NewInt(0), - big.NewInt(0), - r.EVMAddress(), - big.NewInt(time.Now().Add(10*time.Minute).Unix()), - ) - r.ZEVMAuth.Value = previousValue - if err != nil { - return err - } - receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - if receipt.Status == 0 { - return fmt.Errorf("add liquidity failed") - } - - return nil -} - func sendInvalidERC20Deposit(r *runner.E2ERunner, amount *big.Int) (string, error) { tx, err := r.ERC20.Approve(r.EVMAuth, r.ERC20CustodyAddr, amount) if err != nil { diff --git a/e2e/runner/liquidity.go b/e2e/runner/liquidity.go index 4679afbd1a..5f51a9fa3c 100644 --- a/e2e/runner/liquidity.go +++ b/e2e/runner/liquidity.go @@ -37,7 +37,9 @@ func (r *E2ERunner) AddLiquidityETH(amountZETA, amountETH *big.Int) { require.NoError(r, err) receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - require.EqualValues(r, types.ReceiptStatusSuccessful, receipt.Status, "add liquidity failed") + if receipt.Status == types.ReceiptStatusFailed { + r.Logger.Error("Add liquidity failed: %s", receipt.Logs) + } // get the pair address pairAddress, err := r.UniswapV2Factory.GetPair(&bind.CallOpts{}, r.WZetaAddr, r.ETHZRC20Addr) @@ -72,7 +74,9 @@ func (r *E2ERunner) AddLiquidityERC20(amountZETA, amountERC20 *big.Int) { require.NoError(r, err) receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - require.EqualValues(r, types.ReceiptStatusSuccessful, receipt.Status, "add liquidity failed") + if receipt.Status == types.ReceiptStatusFailed { + r.Logger.Error("Add liquidity failed: %s", receipt.Logs) + } // get the pair address pairAddress, err := r.UniswapV2Factory.GetPair(&bind.CallOpts{}, r.WZetaAddr, r.ERC20ZRC20Addr) From 44049ed814d9db05e1b85b0377e7f3b7addddcbd Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 22 Nov 2024 15:00:05 +0100 Subject: [PATCH 3/5] lint --- e2e/e2etests/test_erc20_deposit_refund.go | 3 ++- e2e/runner/liquidity.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/e2etests/test_erc20_deposit_refund.go b/e2e/e2etests/test_erc20_deposit_refund.go index 6823799c38..42584600cc 100644 --- a/e2e/e2etests/test_erc20_deposit_refund.go +++ b/e2e/e2etests/test_erc20_deposit_refund.go @@ -2,10 +2,11 @@ package e2etests import ( "errors" + "math/big" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - "math/big" "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" diff --git a/e2e/runner/liquidity.go b/e2e/runner/liquidity.go index 5f51a9fa3c..43f32b4148 100644 --- a/e2e/runner/liquidity.go +++ b/e2e/runner/liquidity.go @@ -38,7 +38,7 @@ func (r *E2ERunner) AddLiquidityETH(amountZETA, amountETH *big.Int) { receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) if receipt.Status == types.ReceiptStatusFailed { - r.Logger.Error("Add liquidity failed: %s", receipt.Logs) + r.Logger.Error("Add liquidity failed for ZETA/ETH") } // get the pair address @@ -75,7 +75,7 @@ func (r *E2ERunner) AddLiquidityERC20(amountZETA, amountERC20 *big.Int) { receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) if receipt.Status == types.ReceiptStatusFailed { - r.Logger.Error("Add liquidity failed: %s", receipt.Logs) + r.Logger.Error("Add liquidity failed for ZETA/ERC20") } // get the pair address From 1adf91d610abd7cf37afd832f0b3301ef3edc1b2 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 22 Nov 2024 15:48:58 +0100 Subject: [PATCH 4/5] add eth liquidity --- e2e/e2etests/test_erc20_deposit_refund.go | 1 + e2e/utils/require.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/e2e/e2etests/test_erc20_deposit_refund.go b/e2e/e2etests/test_erc20_deposit_refund.go index 42584600cc..1d509af39c 100644 --- a/e2e/e2etests/test_erc20_deposit_refund.go +++ b/e2e/e2etests/test_erc20_deposit_refund.go @@ -63,6 +63,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { r.Logger.Info("Creating the liquidity pool USTD/ZETA") fifty := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(50)) + r.AddLiquidityETH(fifty, fifty) r.AddLiquidityERC20(fifty, fifty) require.NoError(r, err) diff --git a/e2e/utils/require.go b/e2e/utils/require.go index 8bf9c5f5d0..3e8ad6d8a1 100644 --- a/e2e/utils/require.go +++ b/e2e/utils/require.go @@ -16,7 +16,13 @@ func RequireCCTXStatus( expected crosschaintypes.CctxStatus, msgAndArgs ...any, ) { - msg := fmt.Sprintf("cctx status is not %q cctx index %s", expected.String(), cctx.Index) + msg := fmt.Sprintf( + "cctx status is not %q cctx index %s, status: %s, error: %s", + expected.String(), + cctx.Index, + cctx.CctxStatus.StatusMessage, + cctx.CctxStatus.ErrorMessage, + ) require.NotNil(t, cctx.CctxStatus) require.Equal(t, expected, cctx.CctxStatus.Status, msg+errSuffix(msgAndArgs...)) From cab5a37587f417f31a9d515bde74d0da24e12909 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 22 Nov 2024 17:14:12 +0100 Subject: [PATCH 5/5] increase deposit amount --- e2e/e2etests/test_erc20_deposit_refund.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/e2etests/test_erc20_deposit_refund.go b/e2e/e2etests/test_erc20_deposit_refund.go index 1d509af39c..4629d90b06 100644 --- a/e2e/e2etests/test_erc20_deposit_refund.go +++ b/e2e/e2etests/test_erc20_deposit_refund.go @@ -73,7 +73,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) { require.NoError(r, err) // send the deposit - amount = big.NewInt(1e7) + amount = big.NewInt(1e10) inboundHash, err = sendInvalidERC20Deposit(r, amount) require.NoError(r, err)