Skip to content

Commit

Permalink
fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi committed May 15, 2024
1 parent 21208fb commit ddde138
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions system_tests/snap_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ func TestSnapSync(t *testing.T) {
if metadata != metadataNodeC {
t.Error("Batch metadata mismatch")
}
for {
latestHeader, err := builder.L2.Client.HeaderByNumber(ctx, nil)
Require(t, err)
if latestHeader.Number.Uint64() < uint64(metadata.MessageCount)-1 {
<-time.After(10 * time.Millisecond)
} else {
break
}
}
for {
latestHeaderNodeC, err := nodeC.Client.HeaderByNumber(ctx, nil)
Require(t, err)
if latestHeaderNodeC.Number.Uint64() < uint64(metadata.MessageCount)-1 {
<-time.After(10 * time.Millisecond)
} else {
break
}
}
// Fetching message count - 1 instead on the latest block number as the latest block number might not be
// present in the snap sync node since it does not the sequencer feed.
header, err := builder.L2.Client.HeaderByNumber(ctx, big.NewInt(int64(metadata.MessageCount)-1))
Expand Down

0 comments on commit ddde138

Please sign in to comment.