Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: don't hardcode an endpoint #7095

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading