@@ -280,6 +280,19 @@ impl TestFixture {
280280 }
281281}
282282
283+ /// Configuration for Anvil L1 simulation.
284+ #[ derive( Debug , Default , Clone ) ]
285+ pub struct AnvilConfig {
286+ /// Whether to enable Anvil.
287+ pub enabled : bool ,
288+ /// Optional state file to load into Anvil.
289+ pub state_path : Option < PathBuf > ,
290+ /// Optional chain ID for Anvil.
291+ pub chain_id : Option < u64 > ,
292+ /// Optional block time for Anvil (in seconds).
293+ pub block_time : Option < u64 > ,
294+ }
295+
283296/// Builder for creating test fixtures with a fluent API.
284297#[ derive( Debug ) ]
285298pub struct TestFixtureBuilder {
@@ -288,10 +301,7 @@ pub struct TestFixtureBuilder {
288301 chain_spec : Option < Arc < <ScrollRollupNode as NodeTypes >:: ChainSpec > > ,
289302 is_dev : bool ,
290303 no_local_transactions_propagation : bool ,
291- enable_anvil : bool ,
292- anvil_state_path : Option < PathBuf > ,
293- anvil_chain_id : Option < u64 > ,
294- anvil_block_time : Option < u64 > ,
304+ anvil_config : AnvilConfig ,
295305}
296306
297307impl Default for TestFixtureBuilder {
@@ -309,10 +319,7 @@ impl TestFixtureBuilder {
309319 chain_spec : None ,
310320 is_dev : false ,
311321 no_local_transactions_propagation : false ,
312- enable_anvil : false ,
313- anvil_state_path : None ,
314- anvil_chain_id : None ,
315- anvil_block_time : None ,
322+ anvil_config : AnvilConfig :: default ( ) ,
316323 }
317324 }
318325
@@ -515,27 +522,27 @@ impl TestFixtureBuilder {
515522
516523 /// Enable Anvil with the default state file (`./tests/testdata/anvil_state.json`).
517524 pub fn with_anvil ( mut self ) -> Self {
518- self . enable_anvil = true ;
519- self . anvil_state_path = Some ( PathBuf :: from ( "./tests/testdata/anvil_state.json" ) ) ;
525+ self . anvil_config . enabled = true ;
526+ self . anvil_config . state_path = Some ( PathBuf :: from ( "./tests/testdata/anvil_state.json" ) ) ;
520527 self
521528 }
522529
523530 /// Enable Anvil with a custom state file.
524531 pub fn with_anvil_custom_state ( mut self , path : impl Into < PathBuf > ) -> Self {
525- self . enable_anvil = true ;
526- self . anvil_state_path = Some ( path. into ( ) ) ;
532+ self . anvil_config . enabled = true ;
533+ self . anvil_config . state_path = Some ( path. into ( ) ) ;
527534 self
528535 }
529536
530537 /// Set the chain ID for Anvil.
531538 pub const fn with_anvil_chain_id ( mut self , chain_id : u64 ) -> Self {
532- self . anvil_chain_id = Some ( chain_id) ;
539+ self . anvil_config . chain_id = Some ( chain_id) ;
533540 self
534541 }
535542
536543 /// Set the block time for Anvil (in seconds).
537544 pub const fn with_anvil_block_time ( mut self , block_time : u64 ) -> Self {
538- self . anvil_block_time = Some ( block_time) ;
545+ self . anvil_config . block_time = Some ( block_time) ;
539546 self
540547 }
541548
@@ -545,11 +552,11 @@ impl TestFixtureBuilder {
545552 let chain_spec = self . chain_spec . unwrap_or_else ( || SCROLL_DEV . clone ( ) ) ;
546553
547554 // Start Anvil if requested
548- let anvil = if self . enable_anvil {
555+ let anvil = if self . anvil_config . enabled {
549556 let handle = Self :: spawn_anvil (
550- self . anvil_state_path . as_deref ( ) ,
551- self . anvil_chain_id ,
552- self . anvil_block_time ,
557+ self . anvil_config . state_path . as_deref ( ) ,
558+ self . anvil_config . chain_id ,
559+ self . anvil_config . block_time ,
553560 )
554561 . await ?;
555562
0 commit comments