Skip to content

Commit

Permalink
more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Dec 6, 2024
1 parent 0b01b38 commit 24c1e3f
Show file tree
Hide file tree
Showing 37 changed files with 699 additions and 741 deletions.
66 changes: 0 additions & 66 deletions cmd/zetae2e/local/erc20.go

This file was deleted.

60 changes: 0 additions & 60 deletions cmd/zetae2e/local/ethereum.go

This file was deleted.

135 changes: 135 additions & 0 deletions cmd/zetae2e/local/evm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package local

import (
"fmt"
"time"

"github.com/fatih/color"
"golang.org/x/sync/errgroup"

"github.com/zeta-chain/node/e2e/config"
"github.com/zeta-chain/node/e2e/e2etests"
"github.com/zeta-chain/node/e2e/runner"
)

// startEVMTests starts EVM chains related tests in parallel
func startEVMTests(eg *errgroup.Group, conf config.Config, deployerRunner *runner.E2ERunner, verbose bool) {
// Test happy paths for gas token workflow
eg.Go(evmTestRoutine(conf, "eth", conf.AdditionalAccounts.UserV2Ether, color.FgHiGreen, deployerRunner, verbose,
e2etests.TestETHDepositName,
e2etests.TestETHDepositAndCallName,
e2etests.TestETHWithdrawName,
e2etests.TestETHWithdrawAndArbitraryCallName,
e2etests.TestETHWithdrawAndCallName,
e2etests.TestETHWithdrawAndCallThroughContractName,
e2etests.TestZEVMToEVMArbitraryCallName,
e2etests.TestZEVMToEVMCallName,
e2etests.TestZEVMToEVMCallThroughContractName,
e2etests.TestEVMToZEVMCallName,
e2etests.TestETHDepositAndCallNoMessageName,
e2etests.TestETHWithdrawAndCallNoMessageName,
))

// Test happy paths for erc20 token workflow
eg.Go(evmTestRoutine(conf, "erc20", conf.AdditionalAccounts.UserV2ERC20, color.FgHiBlue, deployerRunner, verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestERC20DepositName,
e2etests.TestERC20DepositAndCallName,
e2etests.TestERC20WithdrawName,
e2etests.TestERC20WithdrawAndArbitraryCallName,
e2etests.TestERC20WithdrawAndCallName,
e2etests.TestERC20DepositAndCallNoMessageName,
e2etests.TestERC20WithdrawAndCallNoMessageName,
e2etests.TestDepositAndCallSwapName,
))

// Test revert cases for gas token workflow
eg.Go(
evmTestRoutine(
conf,
"eth-revert",
conf.AdditionalAccounts.UserV2EtherRevert,
color.FgHiYellow,
deployerRunner,
verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestETHDepositAndCallRevertName,
e2etests.TestETHDepositAndCallRevertWithCallName,
e2etests.TestETHWithdrawAndCallRevertName,
e2etests.TestETHWithdrawAndCallRevertWithCallName,
e2etests.TestDepositAndCallOutOfGasName,
),
)

// Test revert cases for erc20 token workflow
eg.Go(
evmTestRoutine(
conf,
"erc20-revert",
conf.AdditionalAccounts.UserV2ERC20Revert,
color.FgHiRed,
deployerRunner,
verbose,
e2etests.TestETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestERC20DepositName, // necessary to have assets to withdraw
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestERC20DepositAndCallRevertName,
e2etests.TestERC20DepositAndCallRevertWithCallName,
e2etests.TestERC20WithdrawAndCallRevertName,
e2etests.TestERC20WithdrawAndCallRevertWithCallName,
),
)
}

// evmTestRoutine runs EVM chain related e2e tests
func evmTestRoutine(
conf config.Config,
name string,
account config.Account,
color color.Attribute,
deployerRunner *runner.E2ERunner,
verbose bool,
testNames ...string,
) func() error {
return func() (err error) {
name = "v2-" + name

// initialize runner for erc20 test
v2Runner, err := initTestRunner(
name,
conf,
deployerRunner,
account,
runner.NewLogger(verbose, color, name),
runner.WithZetaTxServer(deployerRunner.ZetaTxServer),
)
if err != nil {
return err
}

v2Runner.Logger.Print("🏃 starting %s tests", name)
startTime := time.Now()

// funding the account
txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 10000)
v2Runner.WaitForTxReceiptOnEvm(txERC20Send)

// run erc20 test
testsToRun, err := v2Runner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
testNames...,
)
if err != nil {
return fmt.Errorf("%s tests failed: %v", name, err)
}

if err := v2Runner.RunE2ETests(testsToRun); err != nil {
return fmt.Errorf("%s tests failed: %v", name, err)
}

v2Runner.Logger.Print("🍾 %s tests completed in %s", name, time.Since(startTime).String())

return err
}
}
Loading

0 comments on commit 24c1e3f

Please sign in to comment.