Skip to content

Commit

Permalink
refactor BlockchainTestCase::run
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Oct 19, 2024
1 parent 1efa764 commit 96b8c7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions testing/ef-tests/src/cases/blockchain_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
};
use alloy_rlp::Decodable;
use rayon::iter::{ParallelBridge, ParallelIterator};
use reth_chainspec::ChainSpec;
use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment};
use reth_provider::{
providers::StaticFileWriter, test_utils::create_test_provider_factory_with_chain_spec,
Expand Down Expand Up @@ -81,13 +82,12 @@ impl Case for BlockchainTestCase {
)
})
.par_bridge()
.try_for_each(|case| {
.try_for_each(|case: &BlockchainTest| {
// Create a new test database and initialize a provider for the test case.
let provider = create_test_provider_factory_with_chain_spec(Arc::new(
case.network.clone().into(),
))
.database_provider_rw()
.unwrap();
let chain_spec: Arc<ChainSpec> = Arc::new((&case.network).into());
let provider = create_test_provider_factory_with_chain_spec(chain_spec.clone())
.database_provider_rw()
.unwrap();

// Insert initial test state into the provider.
provider.insert_historical_block(
Expand Down Expand Up @@ -127,9 +127,7 @@ impl Case for BlockchainTestCase {
// Execute the execution stage using the EVM processor factory for the test case
// network.
let _ = ExecutionStage::new_with_executor(
reth_evm_ethereum::execute::EthExecutorProvider::ethereum(Arc::new(
case.network.clone().into(),
)),
reth_evm_ethereum::execute::EthExecutorProvider::ethereum(chain_spec),
)
.execute(
&provider,
Expand Down
6 changes: 3 additions & 3 deletions testing/ef-tests/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ pub enum ForkSpec {
Unknown,
}

impl From<ForkSpec> for ChainSpec {
fn from(fork_spec: ForkSpec) -> Self {
impl From<&ForkSpec> for ChainSpec {
fn from(fork_spec: &ForkSpec) -> Self {
let spec_builder = ChainSpecBuilder::mainnet();

match fork_spec {
match *fork_spec {
ForkSpec::Frontier => spec_builder.frontier_activated(),
ForkSpec::Homestead | ForkSpec::FrontierToHomesteadAt5 => {
spec_builder.homestead_activated()
Expand Down

0 comments on commit 96b8c7f

Please sign in to comment.