reth_transaction_pool/test_utils/
mod.rs1use crate::{blobstore::InMemoryBlobStore, noop::MockTransactionValidator, Pool, PoolConfig};
4use std::ops::Deref;
5
6mod tx_gen;
7pub use tx_gen::*;
8
9mod mock;
10pub use mock::*;
11
12mod pool;
13
14mod okvalidator;
15pub use okvalidator::*;
16
17pub type TestPool =
19 Pool<MockTransactionValidator<MockTransaction>, MockOrdering, InMemoryBlobStore>;
20
21#[derive(Debug, Clone)]
23pub struct TestPoolBuilder(TestPool);
24
25impl Default for TestPoolBuilder {
26 fn default() -> Self {
27 Self(Pool::new(
28 MockTransactionValidator::default(),
29 MockOrdering::default(),
30 InMemoryBlobStore::default(),
31 Default::default(),
32 ))
33 }
34}
35
36impl TestPoolBuilder {
37 pub fn with_validator(self, validator: MockTransactionValidator<MockTransaction>) -> Self {
39 Self(Pool::new(
40 validator,
41 MockOrdering::default(),
42 self.pool.blob_store().clone(),
43 self.pool.config().clone(),
44 ))
45 }
46
47 pub fn with_ordering(self, ordering: MockOrdering) -> Self {
49 Self(Pool::new(
50 self.pool.validator().clone(),
51 ordering,
52 self.pool.blob_store().clone(),
53 self.pool.config().clone(),
54 ))
55 }
56
57 pub fn with_blob_store(self, blob_store: InMemoryBlobStore) -> Self {
59 Self(Pool::new(
60 self.pool.validator().clone(),
61 MockOrdering::default(),
62 blob_store,
63 self.pool.config().clone(),
64 ))
65 }
66
67 pub fn with_config(self, config: PoolConfig) -> Self {
69 Self(Pool::new(
70 self.pool.validator().clone(),
71 MockOrdering::default(),
72 self.pool.blob_store().clone(),
73 config,
74 ))
75 }
76}
77
78impl From<TestPoolBuilder> for TestPool {
79 fn from(wrapper: TestPoolBuilder) -> Self {
80 wrapper.0
81 }
82}
83
84impl Deref for TestPoolBuilder {
85 type Target = TestPool;
86
87 fn deref(&self) -> &Self::Target {
88 &self.0
89 }
90}
91
92pub fn testing_pool() -> TestPool {
94 TestPoolBuilder::default().into()
95}