mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
feat(transaction-pool) : impl MockTransaction for Desposit variant (#5321)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
committed by
GitHub
parent
e26bc17531
commit
ee351fc493
@@ -36,6 +36,40 @@ pub fn mock_tx_pool() -> MockTxPool {
|
||||
MockTxPool::new(Default::default(), Default::default())
|
||||
}
|
||||
|
||||
macro_rules! op_set_value {
|
||||
($this:ident, sender, $value:ident) => {
|
||||
$this.from = $value;
|
||||
};
|
||||
($this:ident, gas_limit, $value:ident) => {
|
||||
$this.gas_limit = $value;
|
||||
};
|
||||
($this:ident, value, $value:ident) => {
|
||||
$this.value = $value.into();
|
||||
};
|
||||
($this:ident, input, $value:ident) => {
|
||||
$this.value = $value;
|
||||
};
|
||||
($this:ident, $other:ident, $field:ident) => {};
|
||||
}
|
||||
|
||||
macro_rules! op_get_value {
|
||||
($this:ident, sender) => {
|
||||
$this.from
|
||||
};
|
||||
($this:ident, gas_limit) => {
|
||||
$this.gas_limit
|
||||
};
|
||||
($this:ident, value) => {
|
||||
$this.value.into()
|
||||
};
|
||||
($this:ident, input) => {
|
||||
$this.input.clone()
|
||||
};
|
||||
($this:ident, $other:ident) => {
|
||||
Default::default()
|
||||
};
|
||||
}
|
||||
|
||||
/// Sets the value for the field
|
||||
macro_rules! set_value {
|
||||
($this:ident => $field:ident) => {
|
||||
@@ -54,8 +88,8 @@ macro_rules! set_value {
|
||||
*$field = new_value;
|
||||
}
|
||||
#[cfg(feature = "optimism")]
|
||||
MockTransaction::Deposit(_) => {
|
||||
panic!("not implemented")
|
||||
MockTransaction::Deposit(ref mut tx) => {
|
||||
op_set_value!(tx, $this, new_value);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -63,15 +97,15 @@ macro_rules! set_value {
|
||||
|
||||
/// Gets the value for the field
|
||||
macro_rules! get_value {
|
||||
($this:ident => $field:ident) => {
|
||||
($this:tt => $field:ident) => {
|
||||
match $this {
|
||||
MockTransaction::Legacy { $field, .. } => $field,
|
||||
MockTransaction::Eip1559 { $field, .. } => $field,
|
||||
MockTransaction::Eip4844 { $field, .. } => $field,
|
||||
MockTransaction::Eip2930 { $field, .. } => $field,
|
||||
MockTransaction::Legacy { $field, .. } => $field.clone(),
|
||||
MockTransaction::Eip1559 { $field, .. } => $field.clone(),
|
||||
MockTransaction::Eip4844 { $field, .. } => $field.clone(),
|
||||
MockTransaction::Eip2930 { $field, .. } => $field.clone(),
|
||||
#[cfg(feature = "optimism")]
|
||||
MockTransaction::Deposit(_) => {
|
||||
panic!("not implemented")
|
||||
MockTransaction::Deposit(tx) => {
|
||||
op_get_value!(tx, $field)
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -92,7 +126,7 @@ macro_rules! make_setters_getters {
|
||||
}
|
||||
|
||||
pub fn [<get_ $name>](&self) -> $t {
|
||||
get_value!(self => $name).clone()
|
||||
get_value!(self => $name)
|
||||
}
|
||||
)*}
|
||||
};
|
||||
@@ -308,9 +342,7 @@ impl MockTransaction {
|
||||
}
|
||||
MockTransaction::Eip2930 { gas_price, .. } => *gas_price = val,
|
||||
#[cfg(feature = "optimism")]
|
||||
MockTransaction::Deposit(_) => {
|
||||
panic!("not implemented")
|
||||
}
|
||||
MockTransaction::Deposit(_) => {}
|
||||
}
|
||||
self
|
||||
}
|
||||
@@ -340,9 +372,7 @@ impl MockTransaction {
|
||||
*gas_price = val;
|
||||
}
|
||||
#[cfg(feature = "optimism")]
|
||||
MockTransaction::Deposit(_) => {
|
||||
panic!("not implemented")
|
||||
}
|
||||
MockTransaction::Deposit(_) => {}
|
||||
}
|
||||
self
|
||||
}
|
||||
@@ -724,9 +754,25 @@ impl FromRecoveredTransaction for MockTransaction {
|
||||
accesslist: access_list,
|
||||
},
|
||||
#[cfg(feature = "optimism")]
|
||||
Transaction::Deposit { .. } => {
|
||||
unimplemented!()
|
||||
}
|
||||
Transaction::Deposit(TxDeposit {
|
||||
source_hash,
|
||||
from,
|
||||
to,
|
||||
mint,
|
||||
value,
|
||||
gas_limit,
|
||||
is_system_transaction,
|
||||
input,
|
||||
}) => MockTransaction::Deposit(TxDeposit {
|
||||
source_hash,
|
||||
from,
|
||||
to,
|
||||
mint,
|
||||
value,
|
||||
gas_limit,
|
||||
is_system_transaction,
|
||||
input,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user