@@ -11,6 +11,7 @@ use reth_network_api::{BlockDownloaderProvider, FullNetwork};
1111use reth_network_p2p:: { sync:: SyncState as RethSyncState , FullBlockClient } ;
1212use reth_scroll_node:: ScrollNetworkPrimitives ;
1313use reth_scroll_primitives:: ScrollBlock ;
14+ use reth_tasks:: shutdown:: signal as shutdown_signal;
1415use reth_tasks:: shutdown:: Shutdown ;
1516use reth_tokio_util:: { EventSender , EventStream } ;
1617use rollup_node_primitives:: {
@@ -2210,8 +2211,7 @@ mod tests {
22102211 // initialize database state
22112212 db. set_latest_l1_block_number ( 0 ) . await . unwrap ( ) ;
22122213
2213- println ! ( "done" ) ;
2214- let ( mut chain_orchestrator, handle) = ChainOrchestrator :: new (
2214+ let ( chain_orchestrator, _handle) = ChainOrchestrator :: new (
22152215 db. clone ( ) ,
22162216 ChainOrchestratorConfig :: new ( node. inner . chain_spec ( ) . clone ( ) , 0 , 0 ) ,
22172217 Arc :: new ( block_client) ,
@@ -2241,11 +2241,49 @@ mod tests {
22412241 . unwrap ( ) ;
22422242
22432243
2244- // chain_orchestrator.run_until_shutdown(None)
2245- // TODO: Implement test scenarios:
2246- // 1. Insert batches with non-sequential indices to trigger gap detection
2247- // 2. Feed L1 notifications that trigger gap detection
2248- // 3. Use mock_l1_watcher_handle.assert_reset_to() to verify gap recovery was triggered
2244+ // Spawn a task that constantly polls chain orchestrator to process L1 notifications
2245+ let ( _signal, shutdown) = shutdown_signal ( ) ;
2246+ tokio:: spawn ( async {
2247+ let ( _signal, inner) = shutdown_signal ( ) ;
2248+ let chain_orchestrator = chain_orchestrator. run_until_shutdown ( inner) ;
2249+ tokio:: select! {
2250+ biased;
2251+
2252+ _ = shutdown => { } ,
2253+ _ = chain_orchestrator => { } ,
2254+ }
2255+ } ) ;
2256+
2257+ let genesis_batch = create_test_batch ( 1 , 100 ) ;
2258+ l1_notification_tx. send ( Arc :: new ( L1Notification :: BatchCommit ( genesis_batch) ) ) . await . unwrap ( ) ;
2259+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 50 ) ) . await ;
2260+
2261+ let batch_with_gap = create_test_batch ( 3 , 102 ) ;
2262+ l1_notification_tx. send ( Arc :: new ( L1Notification :: BatchCommit ( batch_with_gap) ) ) . await . unwrap ( ) ;
2263+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 100 ) ) . await ;
2264+
2265+ mock_l1_watcher_handle. assert_reset_to ( 100 ) ;
2266+
2267+
2268+ // Insert first L1 message
2269+ // let l1_msg_0 = create_test_l1_message(0);
2270+ // l1_notification_tx.send(Arc::new(L1Notification::L1Message {
2271+ // message: l1_msg_0,
2272+ // block_number: 105,
2273+ // block_timestamp: 0,
2274+ // })).await.unwrap();
2275+ // tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;
2276+ //
2277+ // let l1_msg_with_gap = create_test_l1_message(2);
2278+ // l1_notification_tx.send(Arc::new(L1Notification::L1Message {
2279+ // message: l1_msg_with_gap,
2280+ // block_number: 107,
2281+ // block_timestamp: 0,
2282+ // })).await.unwrap();
2283+ // tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
2284+ //
2285+ // // Verify that reset was triggered to block 105 (last known L1 message)
2286+ // mock_l1_watcher_handle.assert_reset_to(105);
22492287 }
22502288
22512289 // Helper function to create a simple test batch commit
0 commit comments