test(provider): utility functions for initializing provider factory (#5530)

This commit is contained in:
Roman Krasiuk
2023-11-22 04:56:44 -08:00
committed by GitHub
parent 857ceebbd8
commit 0f1f47ac80

View File

@ -1,3 +1,11 @@
use crate::ProviderFactory;
use reth_db::{
test_utils::{create_test_rw_db, TempDatabase},
DatabaseEnv,
};
use reth_primitives::{ChainSpec, MAINNET};
use std::sync::Arc;
pub mod blocks;
mod events;
mod executor;
@ -8,3 +16,16 @@ pub use events::TestCanonStateSubscriptions;
pub use executor::{TestExecutor, TestExecutorFactory};
pub use mock::{ExtendedAccount, MockEthProvider};
pub use noop::NoopProvider;
/// Creates test provider factory with mainnet chain spec.
pub fn create_test_provider_factory() -> ProviderFactory<Arc<TempDatabase<DatabaseEnv>>> {
create_test_provider_factory_with_chain_spec(MAINNET.clone())
}
/// Creates test provider factory with provided chain spec.
pub fn create_test_provider_factory_with_chain_spec(
chain_spec: Arc<ChainSpec>,
) -> ProviderFactory<Arc<TempDatabase<DatabaseEnv>>> {
let db = create_test_rw_db();
ProviderFactory::new(db, chain_spec)
}