From c2ad1e4cbdee4ac239f35dd15ce787f664a2909d Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 27 Feb 2024 19:14:54 +0100 Subject: [PATCH] Add args description to list tests cmd --- cmd/zetae2e/list_tests.go | 10 +++++++--- e2e/e2etests/e2etests.go | 29 +++++++++++++++++++++++++++++ e2e/e2etests/test_eth_deposit.go | 15 ++++++++++++++- e2e/runner/runner.go | 7 ++++--- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/cmd/zetae2e/list_tests.go b/cmd/zetae2e/list_tests.go index b044d6d0fd..cf59dbedcd 100644 --- a/cmd/zetae2e/list_tests.go +++ b/cmd/zetae2e/list_tests.go @@ -33,16 +33,20 @@ func runListTests(_ *cobra.Command, _ []string) error { func renderTests(logger *runner.Logger, tests []runner.E2ETest) { // Find the maximum length of the Name field maxNameLength := 0 + maxDescriptionLength := 0 for _, test := range tests { if len(test.Name) > maxNameLength { maxNameLength = len(test.Name) } + if len(test.Description) > maxDescriptionLength { + maxDescriptionLength = len(test.Description) + } } // Formatting and printing the table - formatString := fmt.Sprintf("%%-%ds | %%s", maxNameLength) - logger.Print(formatString, "Name", "Description") + formatString := fmt.Sprintf("%%-%ds | %%-%ds | %%s", maxNameLength, maxDescriptionLength) + logger.Print(formatString, "Name", "Description", "Arguments") for _, test := range tests { - logger.Print(formatString, test.Name, test.Description) + logger.Print(formatString, test.Name, test.Description, test.ArgumentsDescription) } } diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index ef6e1cbb74..6fc0c4a56a 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -46,146 +46,175 @@ var AllE2ETests = []runner.E2ETest{ { TestContextUpgradeName, "tests sending ETH on ZEVM and check context data using ContextApp", + "", TestContextUpgrade, }, { TestDepositAndCallRefundName, "deposit ZRC20 into ZEVM and call a contract that reverts; should refund", + "", TestDepositAndCallRefund, }, { TestMultipleERC20DepositName, "deposit USDT ERC20 into ZEVM in multiple deposits", + "", TestMultipleERC20Deposit, }, { TestERC20WithdrawName, "withdraw ERC20 from ZEVM", + "", TestERC20Withdraw, }, { TestMultipleWithdrawsName, "withdraw ERC20 from ZEVM in multiple deposits", + "", TestMultipleWithdraws, }, { TestZetaWithdrawName, "withdraw ZETA from ZEVM to Ethereum", + "", TestZetaWithdraw, }, { TestZetaDepositName, "deposit ZETA from Ethereum to ZEVM", + "", TestZetaDeposit, }, { TestZetaWithdrawBTCRevertName, "sending ZETA from ZEVM to Bitcoin with a message that should revert cctxs", + "", TestZetaWithdrawBTCRevert, }, { TestMessagePassingName, "goerli->goerli message passing (sending ZETA only)", + "", TestMessagePassing, }, { TestZRC20SwapName, "swap ZRC20 USDT for ZRC20 ETH", + "", TestZRC20Swap, }, { TestBitcoinWithdrawName, "withdraw BTC from ZEVM", + "", TestBitcoinWithdraw, }, { TestCrosschainSwapName, "testing Bitcoin ERC20 cross-chain swap", + "", TestCrosschainSwap, }, { TestMessagePassingRevertFailName, "goerli->goerli message passing (revert fail)", + "", TestMessagePassingRevertFail, }, { TestMessagePassingRevertSuccessName, "goerli->goerli message passing (revert success)", + "", TestMessagePassingRevertSuccess, }, { TestPauseZRC20Name, "pausing ZRC20 on ZetaChain", + "", TestPauseZRC20, }, { TestERC20DepositAndCallRefundName, "deposit a non-gas ZRC20 into ZEVM and call a contract that reverts", + "", TestERC20DepositAndCallRefund, }, { TestUpdateBytecodeName, "update ZRC20 bytecode swap", + "", TestUpdateBytecode, }, { TestEtherDepositAndCallName, "deposit ZRC20 into ZEVM and call a contract", + "", TestEtherDepositAndCall, }, { TestDepositEtherLiquidityCapName, "deposit Ethers into ZEVM with a liquidity cap", + "", TestDepositEtherLiquidityCap, }, { TestMyTestName, "performing custom test", + "", TestMyTest, }, { TestERC20DepositName, "deposit ERC20 into ZEVM", + "", TestERC20Deposit, }, { TestEtherDepositName, "deposit Ether into ZEVM", + "amount in wei (default 0.01ETH)", TestEtherDeposit, }, { TestEtherWithdrawName, "withdraw Ether from ZEVM", + "", TestEtherWithdraw, }, { TestBitcoinDepositName, "deposit Bitcoin into ZEVM", + "", TestBitcoinDeposit, }, { TestDonationEtherName, "donate Ether to the TSS", + "", TestDonationEther, }, { TestStressEtherWithdrawName, "stress test Ether withdrawal", + "", TestStressEtherWithdraw, }, { TestStressBTCWithdrawName, "stress test BTC withdrawal", + "", TestStressBTCWithdraw, }, { TestStressEtherDepositName, "stress test Ether deposit", + "", TestStressEtherDeposit, }, { TestStressBTCDepositName, "stress test BTC deposit", + "", TestStressBTCDeposit, }, } diff --git a/e2e/e2etests/test_eth_deposit.go b/e2e/e2etests/test_eth_deposit.go index 912660310c..bdd38b175a 100644 --- a/e2e/e2etests/test_eth_deposit.go +++ b/e2e/e2etests/test_eth_deposit.go @@ -21,7 +21,20 @@ import ( // TestEtherDeposit tests deposit of ethers func TestEtherDeposit(r *runner.E2ERunner, args []string) { - hash := r.DepositEtherWithAmount(false, big.NewInt(10000000000000000)) // in wei (0.01 eth) + defaultAmount := big.NewInt(10000000000000000) // default value of 0.01 ETH in wei + amount := new(big.Int).Set(defaultAmount) + + if len(args) > 1 { + r.Logger.Error("TestEtherDeposit accepts only one argument for the amount, using default value") + } else if len(args) == 1 { + userAmount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + r.Logger.Error("Invalid amount specified for TestEtherDeposit, using default value") + } else { + amount.Set(userAmount) + } + } + hash := r.DepositEtherWithAmount(false, amount) // in wei // wait for the cctx to be mined cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout) diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index b974ed04bb..67bf9dfdf7 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -165,9 +165,10 @@ type E2ETestFunc func(*E2ERunner, []string) // E2ETest represents a E2E test with a name type E2ETest struct { - Name string - Description string - E2ETest E2ETestFunc + Name string + Description string + ArgumentsDescription string + E2ETest E2ETestFunc } // RunE2ETestsFromNames runs a list of E2E tests by name in a list of e2e tests