Skip to content

Commit 8f80042

Browse files
committed
chore: remove ArbitraryTxBuilder
1 parent 17fbd3a commit 8f80042

File tree

3 files changed

+18
-70
lines changed

3 files changed

+18
-70
lines changed

crates/watcher/src/lib.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,10 @@ where
473473
mod tests {
474474
use super::*;
475475

476-
use crate::test_utils::{arbitrary::ArbitraryTxBuilder, provider::MockProvider};
477-
use alloy_consensus::TxType;
476+
use crate::test_utils::provider::MockProvider;
477+
use alloy_consensus::{transaction::Recovered, Signed, TxEip1559};
478+
use alloy_primitives::Address;
479+
use alloy_rpc_types_eth::Transaction;
478480
use alloy_sol_types::{SolCall, SolEvent};
479481
use arbitrary::Arbitrary;
480482
use scroll_l1::abi::calls::commitBatchCall;
@@ -754,10 +756,19 @@ mod tests {
754756
async fn test_handle_batch_commits() -> eyre::Result<()> {
755757
// Given
756758
let (finalized, latest, chain) = chain(10);
757-
let tx = ArbitraryTxBuilder::default()
758-
.with_ty(TxType::Eip1559)
759-
.with_input(random!(commitBatchCall).abi_encode().into())
760-
.build();
759+
760+
// prepare the commit batch call transaction.
761+
let mut inner = random!(Signed<TxEip1559>);
762+
inner.tx_mut().input = random!(commitBatchCall).abi_encode().into();
763+
let recovered = Recovered::new_unchecked(inner.into(), random!(Address));
764+
let tx = Transaction {
765+
inner: recovered,
766+
block_hash: None,
767+
block_number: None,
768+
transaction_index: None,
769+
effective_gas_price: None,
770+
};
771+
761772
let (watcher, mut receiver) =
762773
l1_watcher(chain, vec![], vec![tx.clone()], finalized.clone(), latest.clone());
763774

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
use alloy_consensus::{
2-
transaction::Recovered, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip7702,
3-
TxEnvelope, TxLegacy, TxType,
4-
};
5-
use alloy_primitives::Bytes;
6-
use alloy_rpc_types_eth::Transaction;
7-
use arbitrary::Arbitrary;
8-
91
/// Returns an arbitrary instance of the passed type.
102
#[macro_export]
113
macro_rules! random {
@@ -17,58 +9,3 @@ macro_rules! random {
179
<$typ>::arbitrary(&mut u).unwrap()
1810
}};
1911
}
20-
21-
/// Helper instance to build an arbitrary transaction.
22-
#[derive(Debug)]
23-
pub struct ArbitraryTxBuilder {
24-
tx: Transaction,
25-
}
26-
27-
impl Default for ArbitraryTxBuilder {
28-
fn default() -> Self {
29-
let recovered = random!(Recovered<TxEnvelope>);
30-
Self {
31-
tx: Transaction {
32-
inner: recovered,
33-
block_hash: None,
34-
block_number: None,
35-
transaction_index: None,
36-
effective_gas_price: None,
37-
},
38-
}
39-
}
40-
}
41-
42-
impl ArbitraryTxBuilder {
43-
/// Modifies the type of the random transaction.
44-
pub fn with_ty(mut self, ty: TxType) -> Self {
45-
match ty {
46-
TxType::Legacy => *self.tx.inner.inner_mut() = random!(Signed<TxLegacy>).into(),
47-
TxType::Eip2930 => *self.tx.inner.inner_mut() = random!(Signed<TxEip2930>).into(),
48-
TxType::Eip1559 => *self.tx.inner.inner_mut() = random!(Signed<TxEip1559>).into(),
49-
TxType::Eip4844 => *self.tx.inner.inner_mut() = random!(Signed<TxEip4844>).into(),
50-
TxType::Eip7702 => *self.tx.inner.inner_mut() = random!(Signed<TxEip7702>).into(),
51-
}
52-
self
53-
}
54-
55-
/// Modifies the input of the random transaction.
56-
pub fn with_input(mut self, input: Bytes) -> Self {
57-
match self.tx.inner.inner_mut() {
58-
TxEnvelope::Legacy(ref mut tx) => tx.tx_mut().input = input,
59-
TxEnvelope::Eip2930(ref mut tx) => tx.tx_mut().input = input,
60-
TxEnvelope::Eip1559(ref mut tx) => tx.tx_mut().input = input,
61-
TxEnvelope::Eip4844(ref mut tx) => match tx.tx_mut() {
62-
TxEip4844Variant::TxEip4844(tx) => tx.input = input,
63-
TxEip4844Variant::TxEip4844WithSidecar(tx) => tx.tx.input = input,
64-
},
65-
TxEnvelope::Eip7702(ref mut tx) => tx.tx_mut().input = input,
66-
}
67-
self
68-
}
69-
70-
/// Returns the built transaction.
71-
pub fn build(self) -> Transaction {
72-
self.tx
73-
}
74-
}

crates/watcher/tests/reorg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tracing::{subscriber::set_global_default, Level};
1111

1212
fn setup() {
1313
let sub = tracing_subscriber::FmtSubscriber::builder().with_max_level(Level::TRACE).finish();
14-
set_global_default(sub).expect("failed to set subscriber");
14+
let _ = set_global_default(sub);
1515
}
1616

1717
// Generate a set blocks that will be fed to the l1 watcher.

0 commit comments

Comments
 (0)