refactor: BlockchainTestCase::run rm repetitive convert ForkSpec to ChainSpec (#11896)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
nk_ysg
2024-10-24 13:26:25 +08:00
committed by GitHub
parent d7f08cd876
commit fcca8b1523
2 changed files with 7 additions and 9 deletions

View File

@ -6,6 +6,7 @@ use crate::{
}; };
use alloy_rlp::Decodable; use alloy_rlp::Decodable;
use rayon::iter::{ParallelBridge, ParallelIterator}; use rayon::iter::{ParallelBridge, ParallelIterator};
use reth_chainspec::ChainSpec;
use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment}; use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment};
use reth_provider::{ use reth_provider::{
providers::StaticFileWriter, test_utils::create_test_provider_factory_with_chain_spec, providers::StaticFileWriter, test_utils::create_test_provider_factory_with_chain_spec,
@ -83,11 +84,10 @@ impl Case for BlockchainTestCase {
.par_bridge() .par_bridge()
.try_for_each(|case| { .try_for_each(|case| {
// Create a new test database and initialize a provider for the test case. // Create a new test database and initialize a provider for the test case.
let provider = create_test_provider_factory_with_chain_spec(Arc::new( let chain_spec: Arc<ChainSpec> = Arc::new(case.network.into());
case.network.clone().into(), let provider = create_test_provider_factory_with_chain_spec(chain_spec.clone())
)) .database_provider_rw()
.database_provider_rw() .unwrap();
.unwrap();
// Insert initial test state into the provider. // Insert initial test state into the provider.
provider.insert_historical_block( provider.insert_historical_block(
@ -127,9 +127,7 @@ impl Case for BlockchainTestCase {
// Execute the execution stage using the EVM processor factory for the test case // Execute the execution stage using the EVM processor factory for the test case
// network. // network.
let _ = ExecutionStage::new_with_executor( let _ = ExecutionStage::new_with_executor(
reth_evm_ethereum::execute::EthExecutorProvider::ethereum(Arc::new( reth_evm_ethereum::execute::EthExecutorProvider::ethereum(chain_spec),
case.network.clone().into(),
)),
) )
.execute( .execute(
&provider, &provider,

View File

@ -257,7 +257,7 @@ impl Account {
} }
/// Fork specification. /// Fork specification.
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Ord, Clone, Deserialize)] #[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Ord, Clone, Copy, Deserialize)]
pub enum ForkSpec { pub enum ForkSpec {
/// Frontier /// Frontier
Frontier, Frontier,