Skip to content

Commit 2f65482

Browse files
ArniStarkwaregiladchaseGilad Chase
authored
apollo_integration_tests: ban anvil in unit tests (#8458) (#9723)
Co-authored-by: giladchase <[email protected]> Co-authored-by: Gilad Chase <[email protected]>
1 parent ae63f63 commit 2f65482

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crates/apollo_integration_tests/src/anvil_base_layer.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ impl AnvilBaseLayer {
4444
const DEFAULT_ANVIL_PORT: u16 = 8545;
4545
const DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS: &str = "0x5fbdb2315678afecb367f032d93f642f64180aa3";
4646

47-
/// Note: if you have port conflicts, this is because you are running anvil in unit tests, see
48-
/// usage docstring of the struct. Alternatively, you might have a zombie anvil instance
49-
/// running, but that should be impossible if using this service.
47+
/// Note: if you have port conflicts, you might have a zombie anvil instance
48+
/// running, but that should be impossible if using through this service, you probably have a
49+
/// manually triggered Anvil instance somewhere in your shell.
5050
pub async fn new() -> Self {
51+
let is_unit_test = cfg!(test);
52+
if is_unit_test {
53+
panic!(
54+
"Don't use Anvil in unit tests, only in integration tests defined in the \
55+
integration tests crate. For unit tests, mock l1 using `alloy`'s mocked_provider \
56+
interface."
57+
);
58+
}
59+
5160
// TODO(Arni): Remove the allow(deprecated) once we remove the deprecated function.
5261
#[allow(deprecated)]
5362
let anvil_client = ProviderBuilder::new()

0 commit comments

Comments
 (0)