From 0c06f0aefe786f43d0878da2fde6e49e5c1290cf Mon Sep 17 00:00:00 2001 From: leruaa Date: Sun, 14 Jul 2024 05:03:49 +0000 Subject: [PATCH] feat: impl `arbitrary` for tx structs --- crates/consensus/src/transaction/eip1559.rs | 1 + crates/consensus/src/transaction/eip2930.rs | 1 + crates/consensus/src/transaction/eip4844.rs | 3 +++ crates/consensus/src/transaction/legacy.rs | 1 + 4 files changed, 6 insertions(+) diff --git a/crates/consensus/src/transaction/eip1559.rs b/crates/consensus/src/transaction/eip1559.rs index d195edb9444..4bd890e23c0 100644 --- a/crates/consensus/src/transaction/eip1559.rs +++ b/crates/consensus/src/transaction/eip1559.rs @@ -9,6 +9,7 @@ use alloc::vec::Vec; /// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[doc(alias = "Eip1559Transaction", alias = "TransactionEip1559", alias = "Eip1559Tx")] diff --git a/crates/consensus/src/transaction/eip2930.rs b/crates/consensus/src/transaction/eip2930.rs index 85bb370c178..5cc576861d4 100644 --- a/crates/consensus/src/transaction/eip2930.rs +++ b/crates/consensus/src/transaction/eip2930.rs @@ -9,6 +9,7 @@ use alloc::vec::Vec; /// Transaction with an [`AccessList`] ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)). #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[doc(alias = "Eip2930Transaction", alias = "TransactionEip2930", alias = "Eip2930Tx")] diff --git a/crates/consensus/src/transaction/eip4844.rs b/crates/consensus/src/transaction/eip4844.rs index f7ed416959f..18d2dfaae62 100644 --- a/crates/consensus/src/transaction/eip4844.rs +++ b/crates/consensus/src/transaction/eip4844.rs @@ -22,6 +22,7 @@ use alloc::vec::Vec; /// or a transaction with a sidecar, which is used when submitting a transaction to the network and /// when receiving and sending transactions during the gossip stage. #[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", serde(untagged))] #[doc(alias = "Eip4844TransactionVariant")] @@ -287,6 +288,7 @@ impl SignableTransaction for TxEip4844Variant { /// /// A transaction with blob hashes and max blob fee. It does not have the Blob sidecar. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[doc(alias = "Eip4844Transaction", alias = "TransactionEip4844", alias = "Eip4844Tx")] @@ -704,6 +706,7 @@ impl From for TxEip4844 { /// of a `PooledTransactions` response, and is also used as the format for sending raw transactions /// through the network (eth_sendRawTransaction/eth_sendTransaction). #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[doc(alias = "Eip4844TransactionWithSidecar", alias = "Eip4844TxWithSidecar")] diff --git a/crates/consensus/src/transaction/legacy.rs b/crates/consensus/src/transaction/legacy.rs index c39abfbf186..4b55bea77b5 100644 --- a/crates/consensus/src/transaction/legacy.rs +++ b/crates/consensus/src/transaction/legacy.rs @@ -8,6 +8,7 @@ use alloc::vec::Vec; /// Legacy transaction. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[doc(alias = "LegacyTransaction", alias = "TransactionLegacy", alias = "LegacyTx")]