Skip to content

Commit 0c95ed8

Browse files
committed
chore:improve test
1 parent 1f45689 commit 0c95ed8

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

block/components_test.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ func TestExecutor_RealExecutionClientFailure_StopsNode(t *testing.T) {
210210
Timestamp: time.Now(),
211211
}, nil).Maybe()
212212

213+
// Mock GetTxs for reaper (return empty to avoid interfering with test)
214+
mockExec.On("GetTxs", mock.Anything).
215+
Return([][]byte{}, nil).Maybe()
216+
213217
// Mock ExecuteTxs to fail with a critical error
214218
criticalError := errors.New("execution client RPC connection failed")
215219
mockExec.On("ExecuteTxs", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
@@ -233,15 +237,26 @@ func TestExecutor_RealExecutionClientFailure_StopsNode(t *testing.T) {
233237
require.NoError(t, err)
234238

235239
// Start should return with error when execution client fails
236-
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
240+
// Timeout accounts for retry delays: 3 retries × 10s timeout = ~30s plus buffer
241+
ctx, cancel := context.WithTimeout(context.Background(), 35*time.Second)
237242
defer cancel()
238243

239-
err = components.Start(ctx)
244+
// Run Start in a goroutine to handle the blocking call
245+
startErrCh := make(chan error, 1)
246+
go func() {
247+
startErrCh <- components.Start(ctx)
248+
}()
240249

241-
// We expect an error containing the critical execution client failure
242-
require.Error(t, err)
243-
assert.Contains(t, err.Error(), "critical execution client failure")
244-
assert.Contains(t, err.Error(), "execution client RPC connection failed")
250+
// Wait for either the error or timeout
251+
select {
252+
case err = <-startErrCh:
253+
// We expect an error containing the critical execution client failure
254+
require.Error(t, err)
255+
assert.Contains(t, err.Error(), "critical execution client failure")
256+
assert.Contains(t, err.Error(), "execution client RPC connection failed")
257+
case <-ctx.Done():
258+
t.Fatal("timeout waiting for critical error to propagate")
259+
}
245260

246261
// Clean up
247262
stopErr := components.Stop()

0 commit comments

Comments
 (0)