Skip to content

Commit

Permalink
feat: add arbitrary for alloy types (#1777)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 10, 2024
1 parent 06ad6d7 commit be3f599
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/eips/src/eip1898.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ use core::{
str::FromStr,
};

#[cfg(feature = "serde")]
use serde::ser::SerializeStruct;

/// A helper struct to store the block number/hash and its parent hash.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct BlockWithParent {
/// Parent hash.
pub parent: B256,
Expand Down Expand Up @@ -457,6 +455,8 @@ impl serde::Serialize for BlockId {
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;

match self {
Self::Hash(RpcBlockHash { block_hash, require_canonical }) => {
let mut s = serializer.serialize_struct("BlockIdEip1898", 1)?;
Expand Down Expand Up @@ -644,6 +644,7 @@ impl FromStr for BlockId {
/// A number and a hash.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct NumHash {
/// The number
pub number: u64,
Expand Down

0 comments on commit be3f599

Please sign in to comment.