11use alloy:: { primitives:: U256 , providers:: ext:: AnvilApi } ;
2+ use std:: time:: Duration ;
3+ use tokio:: time:: sleep;
24
35use crate :: common:: { TestCounter , setup_sync_from_latest_scanner} ;
46use event_scanner:: { Notification , assert_empty, assert_event_sequence_final, assert_next} ;
@@ -114,8 +116,11 @@ async fn exact_historical_count_then_live() -> anyhow::Result<()> {
114116 assert_next ! ( stream, Notification :: SwitchingToLive ) ;
115117 let mut stream = assert_empty ! ( stream) ;
116118
119+ // give scanner time to subscribe to live events
120+ sleep ( Duration :: from_millis ( 10 ) ) . await ;
117121 // Live continues
118122 contract. increase ( ) . send ( ) . await ?. watch ( ) . await ?;
123+
119124 assert_next ! ( stream, & [ TestCounter :: CountIncreased { newCount: U256 :: from( 5 ) } ] ) ;
120125 assert_empty ! ( stream) ;
121126
@@ -137,6 +142,8 @@ async fn no_historical_only_live_streams() -> anyhow::Result<()> {
137142 assert_next ! ( stream, Notification :: SwitchingToLive ) ;
138143 let mut stream = assert_empty ! ( stream) ;
139144
145+ // give scanner time to start
146+ sleep ( Duration :: from_millis ( 10 ) ) . await ;
140147 // Live events arrive
141148 contract. increase ( ) . send ( ) . await ?. watch ( ) . await ?;
142149 contract. increase ( ) . send ( ) . await ?. watch ( ) . await ?;
@@ -184,6 +191,8 @@ async fn block_gaps_do_not_affect_number_of_events_streamed() -> anyhow::Result<
184191 assert_next ! ( stream, Notification :: SwitchingToLive ) ;
185192 let mut stream = assert_empty ! ( stream) ;
186193
194+ // give scanner time to start
195+ sleep ( Duration :: from_millis ( 10 ) ) . await ;
187196 // Immediately produce a new live event in a new block
188197 contract. increase ( ) . send ( ) . await ?. watch ( ) . await ?;
189198
0 commit comments