Skip to content

Commit

Permalink
Add args description to list tests cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Feb 27, 2024
1 parent 5e15c14 commit c2ad1e4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
10 changes: 7 additions & 3 deletions cmd/zetae2e/list_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
29 changes: 29 additions & 0 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
15 changes: 14 additions & 1 deletion e2e/e2etests/test_eth_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions e2e/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2ad1e4

Please sign in to comment.