Skip to content

Commit

Permalink
Cleanup and refactor e2e tests functions a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Feb 28, 2024
1 parent fc31ae9 commit fb4b43f
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 255 deletions.
2 changes: 1 addition & 1 deletion cmd/zetae2e/list_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ func renderTests(logger *runner.Logger, tests []runner.E2ETest) {
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, test.ArgumentsDescription)
logger.Print(formatString, test.Name, test.Description, test.ArgsDescription)
}
}
9 changes: 7 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ func adminTestRoutine(
adminRunner.WaitForMinedCCTX(txERC20Deposit)

// run erc20 advanced test
if err := adminRunner.RunE2ETestsFromNames(
testsToRun, err := adminRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestPauseZRC20Name,
e2etests.TestUpdateBytecodeName,
e2etests.TestDepositEtherLiquidityCapName,
); err != nil {
)
if err != nil {
return fmt.Errorf("admin tests failed: %v", err)
}

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

Expand Down
9 changes: 7 additions & 2 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ func bitcoinTestRoutine(
// run bitcoin test
// Note: due to the extensive block generation in Bitcoin localnet, block header test is run first
// to make it faster to catch up with the latest block header
if err := bitcoinRunner.RunE2ETestsFromNames(
testsToRun, err := bitcoinRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestBitcoinWithdrawName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
); err != nil {
)
if err != nil {
return fmt.Errorf("bitcoin tests failed: %v", err)
}

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

Expand Down
9 changes: 7 additions & 2 deletions cmd/zetae2e/local/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ func erc20TestRoutine(
//erc20Runner.DepositBTC()

// run erc20 test
if err := erc20Runner.RunE2ETestsFromNames(
testsToRun, err := erc20Runner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestERC20WithdrawName,
e2etests.TestMultipleWithdrawsName,
e2etests.TestERC20DepositAndCallRefundName,
e2etests.TestZRC20SwapName,
); err != nil {
)
if err != nil {
return fmt.Errorf("erc20 tests failed: %v", err)
}

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

Expand Down
9 changes: 7 additions & 2 deletions cmd/zetae2e/local/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ func ethereumTestRoutine(
// run ethereum test
// Note: due to the extensive block generation in Ethereum localnet, block header test is run first
// to make it faster to catch up with the latest block header
if err := ethereumRunner.RunE2ETestsFromNames(
testsToRun, err := ethereumRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestEtherWithdrawName,
e2etests.TestContextUpgradeName,
e2etests.TestEtherDepositAndCallName,
e2etests.TestDepositAndCallRefundName,
); err != nil {
)
if err != nil {
return fmt.Errorf("ethereum tests failed: %v", err)
}

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

Expand Down
9 changes: 7 additions & 2 deletions cmd/zetae2e/local/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ func miscTestRoutine(
miscRunner.WaitForMinedCCTX(txZetaDeposit)

// run misc test
if err := miscRunner.RunE2ETestsFromNames(
testsToRun, err := miscRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
//e2etests.TestBlockHeadersName,
e2etests.TestMyTestName,
); err != nil {
)
if err != nil {
return fmt.Errorf("misc tests failed: %v", err)
}

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

Expand Down
15 changes: 9 additions & 6 deletions cmd/zetae2e/local/zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ func zetaTestRoutine(
zetaRunner.WaitForMinedCCTX(txEtherDeposit)

// run zeta test
if err := zetaRunner.RunE2ETestsFromNames(
testsToRun, err := zetaRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestZetaWithdrawName,
e2etests.TestMessagePassingName,
e2etests.TestMessagePassingRevertFailName,
e2etests.TestMessagePassingRevertSuccessName,
); err != nil {
//e2etests.TestBlockHeadersName,
e2etests.TestMyTestName,
)
if err != nil {
return fmt.Errorf("zeta tests failed: %v", err)
}

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

Expand Down
18 changes: 10 additions & 8 deletions cmd/zetae2e/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ func runE2ETest(cmd *cobra.Command, args []string) error {
return errors.New("invalid EVM address")
}

// parse test names and arguments
testList := []runner.E2ETest{}
// parse test names and arguments from cmd args
testArgsMap := make(map[string][]string)
for _, arg := range args {
parts := strings.SplitN(arg, ":", 2)
testName := parts[0]
var testArgs []string
testArgs := []string{}
if len(parts) > 1 && parts[1] != "" {
testArgs = strings.Split(parts[1], ",")
}
testList = append(testList, runner.E2ETest{Name: testName, Args: testArgs})
testArgsMap[testName] = testArgs
}

// initialize deployer runner with config
Expand Down Expand Up @@ -129,10 +129,12 @@ func runE2ETest(cmd *cobra.Command, args []string) error {
}

//run tests
reports, err := testRunner.RunE2ETestsFromNamesIntoReport(
e2etests.AllE2ETests,
testList,
)
testsToRun, err := testRunner.GetE2ETestsToRunByNameAndArgs(e2etests.AllE2ETests, testArgsMap)
if err != nil {
cancel()
return err
}
reports, err := testRunner.RunE2ETestsIntoReport(testsToRun)
if err != nil {
cancel()
return err
Expand Down
Loading

0 comments on commit fb4b43f

Please sign in to comment.