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 okvalidator;
13pub use okvalidator::*;
14
15pub type TestPool =
17 Pool<MockTransactionValidator<MockTransaction>, MockOrdering, InMemoryBlobStore>;
18
19#[derive(Debug, Clone)]
21pub struct TestPoolBuilder(TestPool);
22
23impl Default for TestPoolBuilder {
24 fn default() -> Self {
25 Self(Pool::new(
26 MockTransactionValidator::default(),
27 MockOrdering::default(),
28 InMemoryBlobStore::default(),
29 Default::default(),
30 ))
31 }
32}
33
34impl TestPoolBuilder {
35 pub fn with_validator(self, validator: MockTransactionValidator<MockTransaction>) -> Self {
37 Self(Pool::new(
38 validator,
39 MockOrdering::default(),
40 self.pool.blob_store().clone(),
41 self.pool.config().clone(),
42 ))
43 }
44
45 pub fn with_ordering(self, ordering: MockOrdering) -> Self {
47 Self(Pool::new(
48 self.pool.validator().clone(),
49 ordering,
50 self.pool.blob_store().clone(),
51 self.pool.config().clone(),
52 ))
53 }
54
55 pub fn with_blob_store(self, blob_store: InMemoryBlobStore) -> Self {
57 Self(Pool::new(
58 self.pool.validator().clone(),
59 MockOrdering::default(),
60 blob_store,
61 self.pool.config().clone(),
62 ))
63 }
64
65 pub fn with_config(self, config: PoolConfig) -> Self {
67 Self(Pool::new(
68 self.pool.validator().clone(),
69 MockOrdering::default(),
70 self.pool.blob_store().clone(),
71 config,
72 ))
73 }
74}
75
76impl From<TestPoolBuilder> for TestPool {
77 fn from(wrapper: TestPoolBuilder) -> Self {
78 wrapper.0
79 }
80}
81
82impl Deref for TestPoolBuilder {
83 type Target = TestPool;
84
85 fn deref(&self) -> &Self::Target {
86 &self.0
87 }
88}
89
90pub fn testing_pool() -> TestPool {
92 TestPoolBuilder::default().into()
93}