-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The test test_indexer_handles_start_block_configuration in bloklid/tests/indexer_startup_test.rs has a potential flakiness issue. It uses tokio::spawn with a detached task to set requested_start_block, and then relies on a fixed sleep(Duration::from_millis(200)) before asserting the value. This timing-based approach can intermittently fail on slow or loaded CI environments.
Current Implementation
TrackingMockRpc.requested_start_blockis anArc<Mutex<Option<u64>>>- Value is set in a detached task spawned via
tokio::spawn - Test waits a fixed 200ms before checking the value
Proposed Solution
Replace the timing-based approach with a deterministic synchronization mechanism:
- Change
requested_start_blockfromArc<Mutex<Option<u64>>>toArc<tokio::sync::OnceCell<u64>> - Set the value synchronously via
OnceCell::set(...)instead of spawning a task - In the test, await the cell with a bounded wait using
tokio::time::timeoutto fail deterministically if the value never arrives
This ensures the test will either pass reliably or fail quickly with a clear timeout error, rather than racing against arbitrary sleep durations.