@@ -6,11 +6,12 @@ use super::{
66use crate :: {
77 BlobProviderArgs , ChainOrchestratorArgs , ConsensusAlgorithm , ConsensusArgs , EngineDriverArgs ,
88 L1ProviderArgs , RollupNodeDatabaseArgs , RollupNodeGasPriceOracleArgs , RollupNodeNetworkArgs ,
9- RpcArgs , ScrollRollupNode , ScrollRollupNodeConfig , SequencerArgs , SignerArgs ,
9+ RpcArgs , ScrollRollupNode , ScrollRollupNodeConfig , SequencerArgs , SignerArgs , TestArgs ,
1010} ;
1111
1212use alloy_eips:: BlockNumberOrTag ;
13- use alloy_primitives:: Address ;
13+ use alloy_primitives:: { address, Address } ;
14+ use alloy_provider:: { Provider , ProviderBuilder } ;
1415use alloy_rpc_types_eth:: Block ;
1516use alloy_signer_local:: PrivateKeySigner ;
1617use reth_chainspec:: EthChainSpec ;
@@ -230,13 +231,27 @@ impl TestFixture {
230231 self . anvil . is_some ( )
231232 }
232233
234+ /// Generate Anvil blocks by calling anvil_mine RPC method.
235+ pub async fn anvil_mine_blocks ( & self , num_blocks : u64 ) -> eyre:: Result < ( ) > {
236+ // Ensure Anvil is running
237+ let anvil_endpoint =
238+ self . anvil_endpoint ( ) . ok_or_else ( || eyre:: eyre!( "Anvil is not running" ) ) ?;
239+
240+ // Create RPC client
241+ let client = alloy_rpc_client:: RpcClient :: new_http ( anvil_endpoint. parse ( ) ?) ;
242+
243+ // Mine blocks using anvil_mine RPC method
244+ // Parameters: (num_blocks, interval_in_seconds)
245+ let _: ( ) = client. request ( "anvil_mine" , ( num_blocks, 0 ) ) . await ?;
246+
247+ Ok ( ( ) )
248+ }
249+
233250 /// Send a raw transaction to Anvil.
234251 pub async fn anvil_send_raw_transaction (
235252 & self ,
236253 raw_tx : impl Into < alloy_primitives:: Bytes > ,
237254 ) -> eyre:: Result < alloy_primitives:: B256 > {
238- use alloy_provider:: { Provider , ProviderBuilder } ;
239-
240255 // Ensure Anvil is running
241256 let anvil_endpoint =
242257 self . anvil_endpoint ( ) . ok_or_else ( || eyre:: eyre!( "Anvil is not running" ) ) ?;
@@ -294,7 +309,7 @@ impl TestFixtureBuilder {
294309 /// Returns the default rollup node config.
295310 fn default_config ( ) -> ScrollRollupNodeConfig {
296311 ScrollRollupNodeConfig {
297- test : true ,
312+ test_args : TestArgs { test : true , skip_l1_synced : false } ,
298313 network_args : RollupNodeNetworkArgs :: default ( ) ,
299314 database_args : RollupNodeDatabaseArgs :: default ( ) ,
300315 l1_provider_args : L1ProviderArgs :: default ( ) ,
@@ -339,8 +354,15 @@ impl TestFixtureBuilder {
339354 }
340355
341356 /// Toggle the test field.
342- pub const fn with_test ( mut self , test : bool ) -> Self {
343- self . config . test = test;
357+ pub fn with_test ( mut self , test : bool ) -> Self {
358+ self . config . test_args . test = test;
359+ self
360+ }
361+
362+ /// Enable test mode to skip L1 watcher Synced notifications.
363+ /// This is useful for tests that don't want to wait for L1 sync completion events.
364+ pub fn skip_l1_synced_notifications ( mut self ) -> Self {
365+ self . config . test_args . skip_l1_synced = true ;
344366 self
345367 }
346368
@@ -487,7 +509,7 @@ impl TestFixtureBuilder {
487509 self
488510 }
489511
490- /// Enable Anvil with the default state file (`tests/anvil_state.json`).
512+ /// Enable Anvil with the default state file (`./ tests/testdata /anvil_state.json`).
491513 pub fn with_anvil_default_state ( mut self ) -> Self {
492514 self . enable_anvil = true ;
493515 self . anvil_state_path = Some ( PathBuf :: from ( "./tests/testdata/anvil_state.json" ) ) ;
@@ -513,6 +535,23 @@ impl TestFixtureBuilder {
513535 self
514536 }
515537
538+ /// Set custom L1 config addresses for Anvil testing.
539+ /// This method reads contract addresses from tests/anvil.env.
540+ pub fn with_anvil_l1_config ( mut self ) -> Self {
541+ let chain_spec = self . chain_spec . take ( ) . unwrap_or_else ( || SCROLL_DEV . clone ( ) ) ;
542+ let mut spec = ( * chain_spec) . clone ( ) ;
543+ spec. config . l1_config . scroll_chain_address =
544+ address ! ( "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" ) ;
545+ spec. config . l1_config . l1_message_queue_address =
546+ address ! ( "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" ) ;
547+ spec. config . l1_config . l1_message_queue_v2_address =
548+ address ! ( "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" ) ;
549+ spec. config . l1_config . l2_system_config_address =
550+ address ! ( "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" ) ;
551+ self . chain_spec = Some ( Arc :: new ( spec) ) ;
552+ self
553+ }
554+
516555 /// Build the test fixture.
517556 pub async fn build ( self ) -> eyre:: Result < TestFixture > {
518557 let mut config = self . config ;
@@ -609,7 +648,7 @@ impl TestFixtureBuilder {
609648 if let Some ( id) = chain_id {
610649 config. chain_id = Some ( id) ;
611650 }
612-
651+
613652 config. port = 8544 ;
614653
615654 // Configure block time
@@ -619,14 +658,9 @@ impl TestFixtureBuilder {
619658
620659 // Load state from file if provided
621660 if let Some ( path) = state_path {
622- let state = anvil:: eth:: backend:: db:: SerializableState :: load ( path)
623- . map_err ( |e| {
624- eyre:: eyre!(
625- "Failed to load Anvil state from {}: {:?}" ,
626- path. display( ) ,
627- e
628- )
629- } ) ?;
661+ let state = anvil:: eth:: backend:: db:: SerializableState :: load ( path) . map_err ( |e| {
662+ eyre:: eyre!( "Failed to load Anvil state from {}: {:?}" , path. display( ) , e)
663+ } ) ?;
630664 tracing:: info!( "Loaded Anvil state from: {}" , path. display( ) ) ;
631665 config. init_state = Some ( state) ;
632666 }
0 commit comments