Skip to content

Commit

Permalink
test: don't hardcode an endpoint (#7095)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Feb 12, 2024
1 parent 1f19d3c commit 0f746d6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions crates/evm/core/src/fork/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -738,19 +741,21 @@ 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();

let config = Config::figment();
let mut evm_opts = config.extract::<EvmOpts>().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,
};
Expand Down

0 comments on commit 0f746d6

Please sign in to comment.