reth_transaction_pool/test_utils/
mod.rsuse crate::{blobstore::InMemoryBlobStore, noop::MockTransactionValidator, Pool, PoolConfig};
use std::ops::Deref;
mod gen;
pub use gen::*;
mod mock;
pub use mock::*;
mod pool;
pub type TestPool =
Pool<MockTransactionValidator<MockTransaction>, MockOrdering, InMemoryBlobStore>;
#[derive(Debug, Clone)]
pub struct TestPoolBuilder(TestPool);
impl Default for TestPoolBuilder {
fn default() -> Self {
Self(Pool::new(
MockTransactionValidator::default(),
MockOrdering::default(),
InMemoryBlobStore::default(),
Default::default(),
))
}
}
impl TestPoolBuilder {
pub fn with_validator(self, validator: MockTransactionValidator<MockTransaction>) -> Self {
Self(Pool::new(
validator,
MockOrdering::default(),
self.pool.blob_store().clone(),
self.pool.config().clone(),
))
}
pub fn with_ordering(self, ordering: MockOrdering) -> Self {
Self(Pool::new(
self.pool.validator().clone(),
ordering,
self.pool.blob_store().clone(),
self.pool.config().clone(),
))
}
pub fn with_blob_store(self, blob_store: InMemoryBlobStore) -> Self {
Self(Pool::new(
self.pool.validator().clone(),
MockOrdering::default(),
blob_store,
self.pool.config().clone(),
))
}
pub fn with_config(self, config: PoolConfig) -> Self {
Self(Pool::new(
self.pool.validator().clone(),
MockOrdering::default(),
self.pool.blob_store().clone(),
config,
))
}
}
impl From<TestPoolBuilder> for TestPool {
fn from(wrapper: TestPoolBuilder) -> Self {
wrapper.0
}
}
impl Deref for TestPoolBuilder {
type Target = TestPool;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub fn testing_pool() -> TestPool {
TestPoolBuilder::default().into()
}