@@ -2,7 +2,6 @@ use std::collections::HashMap;
22use std:: net:: SocketAddr ;
33use std:: sync:: Arc ;
44
5- use alloy:: node_bindings:: AnvilInstance ;
65use apollo_consensus_manager_config:: config:: ConsensusManagerConfig ;
76use apollo_http_server:: test_utils:: HttpTestClient ;
87use apollo_http_server_config:: config:: HttpServerConfig ;
@@ -31,18 +30,17 @@ use mempool_test_utils::starknet_api_test_utils::{
3130 AccountTransactionGenerator ,
3231 MultiAccountTransactionGenerator ,
3332} ;
33+ use papyrus_base_layer:: anvil_base_layer:: AnvilBaseLayer ;
3434use papyrus_base_layer:: ethereum_base_layer_contract:: {
3535 EthereumBaseLayerConfig ,
3636 L1ToL2MessageArgs ,
37- StarknetL1Contract ,
3837} ;
3938use papyrus_base_layer:: test_utils:: {
40- ethereum_base_layer_config_for_anvil,
4139 make_block_history_on_anvil,
42- spawn_anvil_and_deploy_starknet_l1_contract,
4340 ARBITRARY_ANVIL_L1_ACCOUNT_ADDRESS ,
4441 OTHER_ARBITRARY_ANVIL_L1_ACCOUNT_ADDRESS ,
4542} ;
43+ use papyrus_base_layer:: BaseLayerContract ;
4644use starknet_api:: block:: BlockNumber ;
4745use starknet_api:: consensus_transaction:: ConsensusTransaction ;
4846use starknet_api:: core:: { ChainId , ContractAddress } ;
@@ -78,10 +76,9 @@ pub struct FlowTestSetup {
7876 pub sequencer_0 : FlowSequencerSetup ,
7977 pub sequencer_1 : FlowSequencerSetup ,
8078
81- // Handle for L1 server: the server is dropped when handle is dropped.
82- #[ allow( dead_code) ]
83- l1_handle : AnvilInstance ,
84- starknet_l1_contract : StarknetL1Contract ,
79+ // Ethereum base layer coupled with an Anvil server instance, the server is dropped when the
80+ // instance is dropped.
81+ pub anvil_base_layer : AnvilBaseLayer ,
8582
8683 // The transactions that were streamed in the consensus proposals, used for asserting the right
8784 // transactions are batched.
@@ -122,10 +119,9 @@ impl FlowTestSetup {
122119 . try_into ( )
123120 . unwrap ( ) ;
124121
125- let ( base_layer_config, base_layer_url) =
126- ethereum_base_layer_config_for_anvil ( Some ( available_ports. get_next_port ( ) ) ) ;
127- let ( anvil, starknet_l1_contract) =
128- spawn_anvil_and_deploy_starknet_l1_contract ( & base_layer_config, & base_layer_url) . await ;
122+ let anvil_base_layer = AnvilBaseLayer :: new ( ) . await ;
123+ let base_layer_url = anvil_base_layer. get_url ( ) . await . unwrap ( ) ;
124+ let base_layer_config = anvil_base_layer. ethereum_base_layer . config . clone ( ) ;
129125
130126 // Send some transactions to L1 so it has a history of blocks to scrape gas prices from.
131127 let sender_address = ARBITRARY_ANVIL_L1_ACCOUNT_ADDRESS ;
@@ -181,7 +177,7 @@ impl FlowTestSetup {
181177 )
182178 . await ;
183179
184- Self { sequencer_0, sequencer_1, l1_handle : anvil , starknet_l1_contract , accumulated_txs }
180+ Self { sequencer_0, sequencer_1, anvil_base_layer , accumulated_txs }
185181 }
186182
187183 pub fn chain_id ( & self ) -> & ChainId {
@@ -199,7 +195,11 @@ impl FlowTestSetup {
199195
200196 pub async fn send_messages_to_l2 ( & self , l1_to_l2_messages_args : & [ L1ToL2MessageArgs ] ) {
201197 for l1_to_l2_message_args in l1_to_l2_messages_args {
202- self . starknet_l1_contract . send_message_to_l2 ( l1_to_l2_message_args) . await ;
198+ self . anvil_base_layer
199+ . ethereum_base_layer
200+ . contract
201+ . send_message_to_l2 ( l1_to_l2_message_args)
202+ . await ;
203203 }
204204 }
205205}
0 commit comments