@@ -10,7 +10,7 @@ use reth_tokio_util::EventStream;
1010use rollup_node:: {
1111 test_utils:: {
1212 default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
13- setup_engine,
13+ generate_tx , setup_engine,
1414 } ,
1515 BlobProviderArgs , ChainOrchestratorArgs , ConsensusArgs , EngineDriverArgs , L1ProviderArgs ,
1616 RollupNodeDatabaseArgs , RollupNodeGasPriceOracleArgs , RollupNodeNetworkArgs , RpcArgs ,
@@ -98,6 +98,68 @@ async fn test_should_consolidate_to_block_15k() -> eyre::Result<()> {
9898 Ok ( ( ) )
9999}
100100
101+ #[ allow( clippy:: large_stack_frames) ]
102+ #[ tokio:: test]
103+ async fn test_node_produces_block_on_startup ( ) -> eyre:: Result < ( ) > {
104+ reth_tracing:: init_test_tracing ( ) ;
105+
106+ let mut sequencer_node_config = default_sequencer_test_scroll_rollup_node_config ( ) ;
107+ sequencer_node_config. sequencer_args . auto_start = true ;
108+ sequencer_node_config. sequencer_args . allow_empty_blocks = false ;
109+
110+ let ( mut nodes, _tasks, wallet) =
111+ setup_engine ( sequencer_node_config, 2 , ( * SCROLL_DEV ) . clone ( ) , false , false ) . await ?;
112+
113+ let follower = nodes. pop ( ) . unwrap ( ) ;
114+ let mut follower_events =
115+ follower. inner . add_ons_handle . rollup_manager_handle . get_event_listener ( ) . await ?;
116+ let follower_l1_watcher_tx = follower. inner . add_ons_handle . l1_watcher_tx . clone ( ) . unwrap ( ) ;
117+
118+ let sequencer = nodes. pop ( ) . unwrap ( ) ;
119+ let mut sequencer_events =
120+ sequencer. inner . add_ons_handle . rollup_manager_handle . get_event_listener ( ) . await ?;
121+ let sequencer_l1_watcher_tx = sequencer. inner . add_ons_handle . l1_watcher_tx . clone ( ) . unwrap ( ) ;
122+
123+ // Send a notification to the sequencer and follower nodes that the L1 watcher is synced.
124+ sequencer_l1_watcher_tx. send ( Arc :: new ( L1Notification :: Synced ) ) . await . unwrap ( ) ;
125+ follower_l1_watcher_tx. send ( Arc :: new ( L1Notification :: Synced ) ) . await . unwrap ( ) ;
126+
127+ // wait for both nodes to be synced.
128+ wait_n_events (
129+ & mut sequencer_events,
130+ |e| matches ! ( e, ChainOrchestratorEvent :: ChainConsolidated { from: _, to: _ } ) ,
131+ 1 ,
132+ )
133+ . await ;
134+ wait_n_events (
135+ & mut follower_events,
136+ |e| matches ! ( e, ChainOrchestratorEvent :: ChainConsolidated { from: _, to: _ } ) ,
137+ 1 ,
138+ )
139+ . await ;
140+
141+ // construct a transaction and send it to the follower node.
142+ let wallet = Arc :: new ( tokio:: sync:: Mutex :: new ( wallet) ) ;
143+ let handle = tokio:: spawn ( async move {
144+ loop {
145+ let tx = generate_tx ( wallet. clone ( ) ) . await ;
146+ follower. rpc . inject_tx ( tx) . await . unwrap ( ) ;
147+ }
148+ } ) ;
149+
150+ // Assert that the follower node receives the new block.
151+ wait_n_events (
152+ & mut follower_events,
153+ |e| matches ! ( e, ChainOrchestratorEvent :: ChainExtended ( _) ) ,
154+ 1 ,
155+ )
156+ . await ;
157+
158+ drop ( handle) ;
159+
160+ Ok ( ( ) )
161+ }
162+
101163/// We test if the syncing of the RN is correctly triggered and released when the EN reaches sync.
102164#[ allow( clippy:: large_stack_frames) ]
103165#[ tokio:: test]
0 commit comments