Skip to content

Commit

Permalink
move to a sub function
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jul 14, 2024
1 parent 1ffe907 commit be5054d
Showing 1 changed file with 44 additions and 39 deletions.
83 changes: 44 additions & 39 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,45 +326,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("✅ e2e tests completed in %s", time.Since(testStartTime).String())

if testMigration {
migrationStartTime := time.Now()
logger.Print("🏁 starting tss migration")

response, err := deployerRunner.CctxClient.LastZetaHeight(
deployerRunner.Ctx,
&crosschaintypes.QueryLastZetaHeightRequest{},
)
require.NoError(deployerRunner, err)
err = zetaTxServer.UpdateKeygen(response.Height)
require.NoError(deployerRunner, err)

// Generate new TSS
waitKeygenHeight(deployerRunner.Ctx, deployerRunner.CctxClient, deployerRunner.ObserverClient, logger, 0)

// migration test is a blocking thread, we cannot run other tests in parallel
// The migration test migrates funds to a new TSS and then updates the TSS address on zetacore.
// The necessary restarts are done by the zetaclient supervisor
fn := migrationTestRoutine(conf, deployerRunner, verbose, e2etests.TestMigrateTSSName)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ tss migration failed")
os.Exit(1)
}

logger.Print("✅ migration completed in %s ", time.Since(migrationStartTime).String())
logger.Print("🏁 starting post migration tests")

tests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestEtherWithdrawName,
}
fn = postMigrationTestRoutine(conf, deployerRunner, verbose, tests...)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ post migration tests failed")
os.Exit(1)
}
runTSSMigrationTest(deployerRunner, logger, verbose, conf)
}

// print and validate report
Expand Down Expand Up @@ -418,6 +380,49 @@ func waitKeygenHeight(
}
}

func runTSSMigrationTest(deployerRunner *runner.E2ERunner, logger *runner.Logger, verbose bool, conf config.Config) {
migrationStartTime := time.Now()
logger.Print("🏁 starting tss migration")

response, err := deployerRunner.CctxClient.LastZetaHeight(
deployerRunner.Ctx,
&crosschaintypes.QueryLastZetaHeightRequest{},
)
require.NoError(deployerRunner, err)
err = deployerRunner.ZetaTxServer.UpdateKeygen(response.Height)
require.NoError(deployerRunner, err)

// Generate new TSS
waitKeygenHeight(deployerRunner.Ctx, deployerRunner.CctxClient, deployerRunner.ObserverClient, logger, 0)

// migration test is a blocking thread, we cannot run other tests in parallel
// The migration test migrates funds to a new TSS and then updates the TSS address on zetacore.
// The necessary restarts are done by the zetaclient supervisor
fn := migrationTestRoutine(conf, deployerRunner, verbose, e2etests.TestMigrateTSSName)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ tss migration failed")
os.Exit(1)
}

logger.Print("✅ migration completed in %s ", time.Since(migrationStartTime).String())
logger.Print("🏁 starting post migration tests")

tests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestEtherWithdrawName,
}
fn = postMigrationTestRoutine(conf, deployerRunner, verbose, tests...)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ post migration tests failed")
os.Exit(1)
}

}

func must[T any](v T, err error) T {
return testutil.Must(v, err)
}

0 comments on commit be5054d

Please sign in to comment.