Skip to content

Commit 8adfccf

Browse files
author
Gilad Chase
committed
l1: remove unused test-utils in favor of AnvilBaseLayer
`AnvilBaseLayer` already replaced their usage in previous work. Lingering usage in simulator replaced with manual deploy, this cannot use anvil base layer since it is not using alloy to run Anvil, but manually running it through bash in the github workflow.
1 parent 9a70ca6 commit 8adfccf

File tree

2 files changed

+7
-40
lines changed

2 files changed

+7
-40
lines changed

crates/apollo_integration_tests/src/bin/sequencer_simulator.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ use apollo_integration_tests::utils::{
1313
};
1414
use clap::Parser;
1515
use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator;
16-
use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig;
16+
use papyrus_base_layer::ethereum_base_layer_contract::{
17+
EthereumBaseLayerConfig,
18+
EthereumBaseLayerContract,
19+
Starknet,
20+
};
1721
use papyrus_base_layer::test_utils::{
18-
deploy_starknet_l1_contract,
1922
make_block_history_on_anvil,
2023
DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS,
2124
};
@@ -135,7 +138,8 @@ async fn initialize_anvil_state(sender_address: Address, receiver_address: Addre
135138

136139
let base_layer_config = build_base_layer_config_for_testing();
137140

138-
deploy_starknet_l1_contract(base_layer_config.clone()).await;
141+
let ethereum_base_layer_contract = EthereumBaseLayerContract::new(base_layer_config.clone());
142+
Starknet::deploy(ethereum_base_layer_contract.contract.provider().clone()).await.unwrap();
139143

140144
make_block_history_on_anvil(
141145
sender_address,

crates/papyrus_base_layer/src/test_utils.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@ use starknet_api::hash::StarkHash;
1212
use tar::Archive;
1313
use tempfile::{tempdir, TempDir};
1414
use tracing::debug;
15-
use url::Url;
1615

1716
use crate::ethereum_base_layer_contract::{
1817
EthereumBaseLayerConfig,
1918
EthereumBaseLayerContract,
2019
EthereumContractAddress,
21-
Starknet,
22-
StarknetL1Contract,
2320
};
2421

2522
type TestEthereumNodeHandle = (GanacheInstance, TempDir);
2623

2724
const MINIMAL_GANACHE_VERSION: u8 = 7;
2825

29-
// See Anvil documentation:
30-
// https://docs.rs/ethers-core/latest/ethers_core/utils/struct.Anvil.html#method.new.
31-
const DEFAULT_ANVIL_PORT: u16 = 8545;
3226
// This address is commonly used as the L1 address of the Starknet core contract.
3327
// TODO(Arni): Replace with constant with use of `AnvilInstance::address(&self)`.
3428
pub const DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS: &str = "0x5fbdb2315678afecb367f032d93f642f64180aa3";
@@ -129,37 +123,6 @@ pub fn anvil(port: Option<u16>) -> AnvilInstance {
129123
})
130124
}
131125

132-
pub fn ethereum_base_layer_config_for_anvil(port: Option<u16>) -> EthereumBaseLayerConfig {
133-
// Use the specified port if provided; otherwise, default to Anvil's default port.
134-
let non_optional_port = port.unwrap_or(DEFAULT_ANVIL_PORT);
135-
let endpoint = format!("http://localhost:{non_optional_port}");
136-
EthereumBaseLayerConfig {
137-
node_url: Url::parse(&endpoint).unwrap(),
138-
starknet_contract_address: DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS.parse().unwrap(),
139-
..Default::default()
140-
}
141-
}
142-
143-
pub fn anvil_instance_from_config(config: &EthereumBaseLayerConfig) -> AnvilInstance {
144-
let port = config.node_url.port();
145-
let anvil = anvil(port);
146-
assert_eq!(config.node_url, anvil.endpoint_url(), "Unexpected config for Anvil instance.");
147-
anvil
148-
}
149-
150-
pub async fn spawn_anvil_and_deploy_starknet_l1_contract(
151-
config: &EthereumBaseLayerConfig,
152-
) -> (AnvilInstance, StarknetL1Contract) {
153-
let anvil = anvil_instance_from_config(config);
154-
let starknet_l1_contract = deploy_starknet_l1_contract(config.clone()).await;
155-
(anvil, starknet_l1_contract)
156-
}
157-
158-
pub async fn deploy_starknet_l1_contract(config: EthereumBaseLayerConfig) -> StarknetL1Contract {
159-
let ethereum_base_layer_contract = EthereumBaseLayerContract::new(config);
160-
Starknet::deploy(ethereum_base_layer_contract.contract.provider().clone()).await.unwrap()
161-
}
162-
163126
// FIXME: This should be part of AnvilBaseLayer, however the usage in the simulator doesn't allow
164127
// that, since it is coupled with a manual invocation of an anvil instance that is managed inside
165128
// the github workflow.

0 commit comments

Comments
 (0)