From 25a3461f2d2b34cd4ed4fffa773aeaf68f745fe3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:38:49 +0100 Subject: [PATCH] test: don't hardcode an endpoint --- crates/evm/core/src/fork/backend.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index eb3638ecea87..4223e2dea772 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -684,15 +684,18 @@ mod tests { use foundry_common::provider::alloy::get_http_provider; use foundry_config::{Config, NamedChain}; use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; - const ENDPOINT: &str = "https://mainnet.infura.io/v3/40bee2d557ed4b52908c3e62345a3d8b"; + + const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); #[tokio::test(flavor = "multi_thread")] async fn shared_backend() { - let provider = get_http_provider(ENDPOINT); + let Some(endpoint) = ENDPOINT else { return }; + + let provider = get_http_provider(endpoint); let meta = BlockchainDbMeta { cfg_env: Default::default(), block_env: Default::default(), - hosts: BTreeSet::from([ENDPOINT.to_string()]), + hosts: BTreeSet::from([endpoint.to_string()]), }; let db = BlockchainDb::new(meta, None); @@ -738,7 +741,9 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn can_read_write_cache() { - let provider = get_http_provider(ENDPOINT); + let Some(endpoint) = ENDPOINT else { return }; + + let provider = get_http_provider(endpoint); let block_num = provider.get_block_number().await.unwrap(); @@ -746,11 +751,11 @@ mod tests { let mut evm_opts = config.extract::().unwrap(); evm_opts.fork_block_number = Some(block_num); - let (env, _block) = evm_opts.fork_evm_env(ENDPOINT).await.unwrap(); + let (env, _block) = evm_opts.fork_evm_env(endpoint).await.unwrap(); let fork = CreateFork { enable_caching: true, - url: ENDPOINT.to_string(), + url: endpoint.to_string(), env: env.clone(), evm_opts, };