Commit 474abd9c authored by Adrian Sutton's avatar Adrian Sutton

op-e2e: Use a long timeout when waiting for next block and keep test code simple.

parent 3618dbb1
...@@ -49,18 +49,11 @@ func ForBlockWithTimestamp(ctx context.Context, client BlockCaller, target uint6 ...@@ -49,18 +49,11 @@ func ForBlockWithTimestamp(ctx context.Context, client BlockCaller, target uint6
func ForNextBlock(ctx context.Context, client BlockCaller) error { func ForNextBlock(ctx context.Context, client BlockCaller) error {
current, err := client.BlockNumber(ctx) current, err := client.BlockNumber(ctx)
if err != nil { // Long timeout so we don't have to care what the block time is. If the test passes this will complete early anyway.
return fmt.Errorf("get starting block number: %w", err) ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
}
return ForBlock(ctx, client, current+1)
}
func ForNextBlockWithTimeout(ctx context.Context, client BlockCaller, timeout time.Duration) error {
timeoutCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel() defer cancel()
current, err := client.BlockNumber(ctx)
if err != nil { if err != nil {
return fmt.Errorf("get starting block number: %w", err) return fmt.Errorf("get starting block number: %w", err)
} }
return ForBlock(timeoutCtx, client, current+1) return ForBlock(ctx, client, current+1)
} }
...@@ -37,7 +37,7 @@ func TestStopStartSequencer(t *testing.T) { ...@@ -37,7 +37,7 @@ func TestStopStartSequencer(t *testing.T) {
require.NoError( require.NoError(
t, t,
wait.ForNextBlockWithTimeout(ctx, l2Seq, time.Duration(cfg.DeployConfig.L2BlockTime+1)*2*time.Second), wait.ForNextBlock(ctx, l2Seq),
"Chain did not advance after starting sequencer", "Chain did not advance after starting sequencer",
) )
...@@ -70,7 +70,7 @@ func TestStopStartSequencer(t *testing.T) { ...@@ -70,7 +70,7 @@ func TestStopStartSequencer(t *testing.T) {
require.NoError( require.NoError(
t, t,
wait.ForNextBlockWithTimeout(ctx, l2Seq, time.Duration(cfg.DeployConfig.L2BlockTime+1)*2*time.Second), wait.ForNextBlock(ctx, l2Seq),
"Chain did not advance after starting sequencer", "Chain did not advance after starting sequencer",
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment