@@ -10,7 +10,7 @@ use crate::{
1010} ;
1111
1212use alloy_eips:: BlockNumberOrTag ;
13- use alloy_primitives:: { Address , BlockHash } ;
13+ use alloy_primitives:: Address ;
1414use alloy_rpc_types_eth:: Block ;
1515use alloy_signer_local:: PrivateKeySigner ;
1616use reth_chainspec:: EthChainSpec ;
@@ -89,12 +89,12 @@ pub struct NodeHandle {
8989
9090impl NodeHandle {
9191 /// Returns true if this is a handle to the sequencer.
92- pub fn is_sequencer ( & self ) -> bool {
92+ pub const fn is_sequencer ( & self ) -> bool {
9393 matches ! ( self . typ, NodeType :: Sequencer )
9494 }
9595
9696 /// Returns true if this is a handle to a follower.
97- pub fn is_follower ( & self ) -> bool {
97+ pub const fn is_follower ( & self ) -> bool {
9898 matches ! ( self . typ, NodeType :: Follower )
9999 }
100100}
@@ -120,9 +120,7 @@ impl TestFixture {
120120 /// Get the sequencer node (assumes first node is sequencer).
121121 pub fn sequencer ( & mut self ) -> & mut NodeHandle {
122122 let handle = & mut self . nodes [ 0 ] ;
123- if !handle. is_sequencer ( ) {
124- panic ! ( "expected sequencer, got follower" )
125- }
123+ assert ! ( handle. is_sequencer( ) , "expected sequencer, got follower" ) ;
126124 handle
127125 }
128126
@@ -159,54 +157,6 @@ impl TestFixture {
159157 self . tx ( ) . transfer ( ) . inject ( ) . await
160158 }
161159
162- /// Advance time by sleeping for the specified number of seconds.
163- pub async fn advance_time ( & self , seconds : u64 ) {
164- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( seconds) ) . await ;
165- }
166-
167- /// Connect all nodes in a mesh network.
168- pub async fn connect_all ( & mut self ) {
169- let node_count = self . nodes . len ( ) ;
170- for i in 0 ..node_count {
171- for j in ( i + 1 ) ..node_count {
172- self . connect ( i, j) . await ;
173- }
174- }
175- }
176-
177- /// Connect two nodes by index.
178- pub async fn connect ( & mut self , idx1 : usize , idx2 : usize ) {
179- // Split the nodes vector to get mutable references to both nodes
180- if idx1 == idx2 {
181- return ;
182- }
183-
184- let ( node1, node2) = if idx1 < idx2 {
185- let ( left, right) = self . nodes . split_at_mut ( idx2) ;
186- ( & mut left[ idx1] , & mut right[ 0 ] )
187- } else {
188- let ( left, right) = self . nodes . split_at_mut ( idx1) ;
189- ( & mut right[ 0 ] , & mut left[ idx2] )
190- } ;
191-
192- node1. node . connect ( & mut node2. node ) . await ;
193- }
194-
195- /// Get the genesis hash from the chain spec.
196- pub fn genesis_hash ( & self ) -> BlockHash {
197- self . chain_spec . genesis_hash ( )
198- }
199-
200- /// Get the chain ID.
201- pub fn chain_id ( & self ) -> u64 {
202- self . chain_spec . chain ( ) . into ( )
203- }
204-
205- /// Get the RPC URL for a specific node.
206- pub fn rpc_url ( & self , node_index : usize ) -> String {
207- format ! ( "http://localhost:{}" , self . nodes[ node_index] . node. rpc_url( ) . port( ) . unwrap( ) )
208- }
209-
210160 /// Inject a raw transaction into a specific node's pool.
211161 pub async fn inject_tx_on (
212162 & mut self ,
@@ -235,24 +185,6 @@ impl TestFixture {
235185 pub async fn get_sequencer_block ( & self ) -> eyre:: Result < Block < Transaction > > {
236186 self . get_block ( 0 ) . await
237187 }
238-
239- /// Get a block by number from a specific node.
240- pub async fn get_block_by_number (
241- & self ,
242- node_index : usize ,
243- block_number : impl Into < BlockNumberOrTag > ,
244- ) -> eyre:: Result < Option < Block < Transaction > > > {
245- use reth_rpc_api:: EthApiServer ;
246-
247- self . nodes [ node_index]
248- . node
249- . rpc
250- . inner
251- . eth_api ( )
252- . block_by_number ( block_number. into ( ) , false )
253- . await
254- . map_err ( Into :: into)
255- }
256188}
257189
258190/// Builder for creating test fixtures with a fluent API.
@@ -325,13 +257,13 @@ impl TestFixtureBuilder {
325257 }
326258
327259 /// Adds `count`s follower nodes to the test.
328- pub fn followers ( mut self , count : usize ) -> TestFixtureBuilder {
260+ pub const fn followers ( mut self , count : usize ) -> Self {
329261 self . num_nodes += count;
330262 self
331263 }
332264
333265 /// Toggle the test field.
334- pub fn with_test ( mut self , test : bool ) -> Self {
266+ pub const fn with_test ( mut self , test : bool ) -> Self {
335267 self . config . test = test;
336268 self
337269 }
@@ -343,7 +275,7 @@ impl TestFixtureBuilder {
343275 }
344276
345277 /// Set the sequencer auto start for the node.
346- pub fn with_sequencer_auto_start ( mut self , auto_start : bool ) -> Self {
278+ pub const fn with_sequencer_auto_start ( mut self , auto_start : bool ) -> Self {
347279 self . config . sequencer_args . auto_start = auto_start;
348280 self
349281 }
@@ -370,26 +302,26 @@ impl TestFixtureBuilder {
370302 }
371303
372304 /// Set the block time for the sequencer.
373- pub fn block_time ( mut self , millis : u64 ) -> Self {
305+ pub const fn block_time ( mut self , millis : u64 ) -> Self {
374306 self . config . sequencer_args . block_time = millis;
375307 self
376308 }
377309
378310 /// Set whether to allow empty blocks.
379- pub fn allow_empty_blocks ( mut self , allow : bool ) -> Self {
311+ pub const fn allow_empty_blocks ( mut self , allow : bool ) -> Self {
380312 self . config . sequencer_args . allow_empty_blocks = allow;
381313 self
382314 }
383315
384316 /// Set L1 message inclusion mode with block depth.
385- pub fn with_l1_message_delay ( mut self , depth : u64 ) -> Self {
317+ pub const fn with_l1_message_delay ( mut self , depth : u64 ) -> Self {
386318 self . config . sequencer_args . l1_message_inclusion_mode =
387319 L1MessageInclusionMode :: BlockDepth ( depth) ;
388320 self
389321 }
390322
391323 /// Set L1 message inclusion mode to finalized with optional block depth.
392- pub fn with_finalized_l1_messages ( mut self , depth : u64 ) -> Self {
324+ pub const fn with_finalized_l1_messages ( mut self , depth : u64 ) -> Self {
393325 self . config . sequencer_args . l1_message_inclusion_mode =
394326 L1MessageInclusionMode :: FinalizedWithBlockDepth ( depth) ;
395327 self
@@ -408,13 +340,13 @@ impl TestFixtureBuilder {
408340 }
409341
410342 /// Use noop consensus (no validation).
411- pub fn with_noop_consensus ( mut self ) -> Self {
343+ pub const fn with_noop_consensus ( mut self ) -> Self {
412344 self . config . consensus_args = ConsensusArgs :: noop ( ) ;
413345 self
414346 }
415347
416- /// Use SystemContract consensus with the given authorized signer address.
417- pub fn with_consensus_system_contract ( mut self , authorized_signer : Address ) -> Self {
348+ /// Use ` SystemContract` consensus with the given authorized signer address.
349+ pub const fn with_consensus_system_contract ( mut self , authorized_signer : Address ) -> Self {
418350 self . config . consensus_args . algorithm = ConsensusAlgorithm :: SystemContract ;
419351 self . config . consensus_args . authorized_signer = Some ( authorized_signer) ;
420352 self
@@ -427,59 +359,47 @@ impl TestFixtureBuilder {
427359 }
428360
429361 /// Set the payload building duration in milliseconds.
430- pub fn payload_building_duration ( mut self , millis : u64 ) -> Self {
362+ pub const fn payload_building_duration ( mut self , millis : u64 ) -> Self {
431363 self . config . sequencer_args . payload_building_duration = millis;
432364 self
433365 }
434366
435367 /// Set the fee recipient address.
436- pub fn fee_recipient ( mut self , address : Address ) -> Self {
368+ pub const fn fee_recipient ( mut self , address : Address ) -> Self {
437369 self . config . sequencer_args . fee_recipient = address;
438370 self
439371 }
440372
441373 /// Enable auto-start for the sequencer.
442- pub fn auto_start ( mut self , enabled : bool ) -> Self {
374+ pub const fn auto_start ( mut self , enabled : bool ) -> Self {
443375 self . config . sequencer_args . auto_start = enabled;
444376 self
445377 }
446378
447379 /// Set the maximum number of L1 messages per block.
448- pub fn max_l1_messages ( mut self , max : u64 ) -> Self {
380+ pub const fn max_l1_messages ( mut self , max : u64 ) -> Self {
449381 self . config . sequencer_args . max_l1_messages = Some ( max) ;
450382 self
451383 }
452384
453385 /// Enable the Scroll wire protocol.
454- pub fn with_scroll_wire ( mut self , enabled : bool ) -> Self {
386+ pub const fn with_scroll_wire ( mut self , enabled : bool ) -> Self {
455387 self . config . network_args . enable_scroll_wire = enabled;
456388 self
457389 }
458390
459391 /// Enable the ETH-Scroll wire bridge.
460- pub fn with_eth_scroll_bridge ( mut self , enabled : bool ) -> Self {
392+ pub const fn with_eth_scroll_bridge ( mut self , enabled : bool ) -> Self {
461393 self . config . network_args . enable_eth_scroll_wire_bridge = enabled;
462394 self
463395 }
464396
465397 /// Set the optimistic sync trigger threshold.
466- pub fn optimistic_sync_trigger ( mut self , blocks : u64 ) -> Self {
398+ pub const fn optimistic_sync_trigger ( mut self , blocks : u64 ) -> Self {
467399 self . config . chain_orchestrator_args . optimistic_sync_trigger = blocks;
468400 self
469401 }
470402
471- /// Set the chain buffer size.
472- pub fn chain_buffer_size ( mut self , size : usize ) -> Self {
473- self . config . chain_orchestrator_args . chain_buffer_size = size;
474- self
475- }
476-
477- /// Disable the test mode (enables real signing).
478- pub fn production_mode ( mut self ) -> Self {
479- self . config . test = false ;
480- self
481- }
482-
483403 /// Get a mutable reference to the underlying config for advanced customization.
484404 pub fn config_mut ( & mut self ) -> & mut ScrollRollupNodeConfig {
485405 & mut self . config
0 commit comments