From 84fd550dff15bee8cbdf07144b40a8cb971a6888 Mon Sep 17 00:00:00 2001 From: bros Date: Wed, 21 Aug 2024 08:42:21 +0000 Subject: [PATCH] fix UTs --- bridgesync/e2e_test.go | 2 +- cmd/run.go | 75 ------------------------------------------ 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index b61454bf..d733a53e 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -97,7 +97,7 @@ func TestBridgeEventE2E(t *testing.T) { syncerUpToDate = true break } - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 100) errMsg = fmt.Sprintf("last block from client: %d, last block from syncer: %d", lb, lpb) } require.True(t, syncerUpToDate, errMsg) diff --git a/cmd/run.go b/cmd/run.go index 2b4aa149..c17c4676 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -685,78 +685,3 @@ func createRPC( }, }) } - -func isNeeded(casesWhereNeeded, actualCases []string) bool { - for _, actaulCase := range actualCases { - for _, caseWhereNeeded := range casesWhereNeeded { - if actaulCase == caseWhereNeeded { - return true - } - } - } - return false -} - -func runL1InfoTreeSyncerIfNeeded( - ctx context.Context, - components []string, - cfg config.Config, - l1Client *ethclient.Client, - reorgDetector *reorgdetector.ReorgDetector, -) *l1infotreesync.L1InfoTreeSync { - if !isNeeded([]string{AGGORACLE, SEQUENCE_SENDER}, components) { - return nil - } - l1InfoTreeSync, err := l1infotreesync.New( - ctx, - cfg.L1InfoTreeSync.DBPath, - cfg.L1InfoTreeSync.GlobalExitRootAddr, - cfg.L1InfoTreeSync.RollupManagerAddr, - cfg.L1InfoTreeSync.SyncBlockChunkSize, - etherman.BlockNumberFinality(cfg.L1InfoTreeSync.BlockFinality), - reorgDetector, - l1Client, - cfg.L1InfoTreeSync.WaitForNewBlocksPeriod.Duration, - cfg.L1InfoTreeSync.InitialBlock, - cfg.L1InfoTreeSync.RetryAfterErrorPeriod.Duration, - cfg.L1InfoTreeSync.MaxRetryAttemptsAfterError, - ) - if err != nil { - log.Fatal(err) - } - go l1InfoTreeSync.Start(ctx) - return l1InfoTreeSync -} - -func runL1ClientIfNeeded(components []string, urlRPCL1 string) *ethclient.Client { - if !isNeeded([]string{SEQUENCE_SENDER, AGGREGATOR, AGGORACLE}, components) { - return nil - } - log.Debugf("dialing L1 client at: %s", urlRPCL1) - l1CLient, err := ethclient.Dial(urlRPCL1) - if err != nil { - log.Fatal(err) - } - return l1CLient -} - -func runReorgDetectorL1IfNeeded(ctx context.Context, components []string, l1Client *ethclient.Client, dbPath string) *reorgdetector.ReorgDetector { - if !isNeeded([]string{SEQUENCE_SENDER, AGGREGATOR, AGGORACLE}, components) { - return nil - } - rd := newReorgDetector(ctx, dbPath, l1Client) - go rd.Start(ctx) - return rd -} - -func newReorgDetector( - ctx context.Context, - dbPath string, - client *ethclient.Client, -) *reorgdetector.ReorgDetector { - rd, err := reorgdetector.New(ctx, client, dbPath) - if err != nil { - log.Fatal(err) - } - return rd -}