Skip to content

Commit

Permalink
fix UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Aug 21, 2024
1 parent 028f85d commit 84fd550
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 76 deletions.
2 changes: 1 addition & 1 deletion bridgesync/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
75 changes: 0 additions & 75 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 84fd550

Please sign in to comment.