Skip to content

Commit

Permalink
fix(test): move uses to mainnet_blocks_from_rpc
Browse files Browse the repository at this point in the history
move some uses to remove annoying warnings
  • Loading branch information
fiplox committed Nov 8, 2024
1 parent 36c574e commit 8a9e05f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions crates/pevm/tests/mainnet.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#![allow(unused_crate_dependencies)]

use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types::{BlockId, BlockTransactionsKind};
use reqwest::Url;

use pevm::chain::{PevmChain, PevmEthereum};
use pevm::chain::PevmEthereum;

pub mod common;

#[tokio::test(flavor = "multi_thread")]
#[cfg(feature = "rpc-storage")]
async fn mainnet_blocks_from_rpc() {
use alloy_provider::{Provider, ProviderBuilder};
use pevm::chain::PevmChain;

let rpc_url = match std::env::var("ETHEREUM_RPC_URL") {
// The empty check is for GitHub Actions where the variable is set with an empty string when unset!?
Ok(value) if !value.is_empty() => value.parse().unwrap(),
_ => Url::parse("https://eth.public-rpc.com").unwrap(),
_ => reqwest::Url::parse("https://eth.public-rpc.com").unwrap(),
};

// First block under 50 transactions of each EVM-spec-changing fork
Expand All @@ -35,14 +34,20 @@ async fn mainnet_blocks_from_rpc() {
] {
let provider = ProviderBuilder::new().on_http(rpc_url.clone());
let block = provider
.get_block(BlockId::number(block_number), BlockTransactionsKind::Full)
.get_block(
alloy_rpc_types::BlockId::number(block_number),
alloy_rpc_types::BlockTransactionsKind::Full,
)
.await
.unwrap()
.unwrap();
let chain = PevmEthereum::mainnet();
let spec_id = chain.get_block_spec(&block.header).unwrap();
let rpc_storage =
pevm::RpcStorage::new(provider, spec_id, BlockId::number(block_number - 1));
let rpc_storage = pevm::RpcStorage::new(
provider,
spec_id,
alloy_rpc_types::BlockId::number(block_number - 1),
);
common::test_execute_alloy(&rpc_storage, &chain, block, true);
}
}
Expand Down

0 comments on commit 8a9e05f

Please sign in to comment.