@@ -455,6 +455,34 @@ async fn dep_chain_id_for_output_handle(
455455 Ok ( dep_chain_id)
456456}
457457
458+ // Polls Anvil until the block number advances past `after_block`.
459+ // If `after_block` is `None`, queries the current block first.
460+ async fn wait_for_next_block (
461+ url : & str ,
462+ after_block : Option < u64 > ,
463+ timeout : tokio:: time:: Duration ,
464+ ) -> Result < u64 , anyhow:: Error > {
465+ let provider = ProviderBuilder :: new ( )
466+ . connect_ws ( WsConnect :: new ( url) )
467+ . await ?;
468+ let current = match after_block {
469+ Some ( b) => b,
470+ None => provider. get_block_number ( ) . await ?,
471+ } ;
472+ let deadline = tokio:: time:: Instant :: now ( ) + timeout;
473+ loop {
474+ let block = provider. get_block_number ( ) . await ?;
475+ if block > current {
476+ return Ok ( block) ;
477+ }
478+ assert ! (
479+ tokio:: time:: Instant :: now( ) < deadline,
480+ "timeout waiting for block > {current}, still at {block}"
481+ ) ;
482+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 100 ) ) . await ;
483+ }
484+ }
485+
458486// Polls the database until both `computations` and `allowed_handles` counts
459487// satisfy `predicate`, returning the final `(tfhe_count, acl_count)`.
460488// Panics with `context` if `timeout` elapses before the condition is met.
@@ -616,7 +644,7 @@ async fn test_schedule_priority_migration_contract() -> Result<(), anyhow::Error
616644#[ serial( db) ]
617645async fn test_slow_lane_cross_block_sustained_below_cap_stays_fast_locally (
618646) -> Result < ( ) , anyhow:: Error > {
619- let setup = setup_with_block_time ( None , 3 .0) . await ?;
647+ let setup = setup_with_block_time ( None , 1 .0) . await ?;
620648 let mut db = Database :: new (
621649 & setup. args . database_url ,
622650 setup. chain_id ,
@@ -660,7 +688,16 @@ async fn test_slow_lane_cross_block_sustained_below_cap_stays_fast_locally(
660688 . await ?;
661689
662690 current_handle = Some ( last_output_handle) ;
663- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 4 ) ) . await ;
691+ let last_block = receipts
692+ . last ( )
693+ . and_then ( |r| r. block_number )
694+ . expect ( "receipt has block number" ) ;
695+ wait_for_next_block (
696+ & setup. args . url ,
697+ Some ( last_block) ,
698+ tokio:: time:: Duration :: from_secs ( 10 ) ,
699+ )
700+ . await ?;
664701 }
665702
666703 assert ! (
@@ -743,7 +780,7 @@ async fn test_slow_lane_cross_block_parent_lookup_finds_known_slow_parent_locall
743780#[ serial( db) ]
744781async fn test_slow_lane_priority_is_monotonic_across_blocks_locally (
745782) -> Result < ( ) , anyhow:: Error > {
746- let setup = setup_with_block_time ( None , 3 .0) . await ?;
783+ let setup = setup_with_block_time ( None , 1 .0) . await ?;
747784 let mut db = Database :: new (
748785 & setup. args . database_url ,
749786 setup. chain_id ,
@@ -764,7 +801,12 @@ async fn test_slow_lane_priority_is_monotonic_across_blocks_locally(
764801 . await ?;
765802 assert_eq ! ( initial_priority, 1 , "first pass should mark chain slow" ) ;
766803
767- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 4 ) ) . await ;
804+ wait_for_next_block (
805+ & setup. args . url ,
806+ None ,
807+ tokio:: time:: Duration :: from_secs ( 10 ) ,
808+ )
809+ . await ?;
768810
769811 let second_output = ingest_dependent_burst_seeded (
770812 & mut db,
0 commit comments