-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
699 additions
and
741 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.