Skip to content

Commit

Permalink
Merge pull request #8 from anton-rs/rf/more/arbitrary
Browse files Browse the repository at this point in the history
feat(primitives): Block Arbitrary Impl
  • Loading branch information
refcell authored Sep 4, 2024
2 parents c8bd1b9 + 4f71ca4 commit 168af3f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use core::fmt::Display;
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct BlockID {
/// Block hash
pub hash: B256,
Expand All @@ -23,3 +24,18 @@ impl Display for BlockID {
)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_block_id_display() {
let block_id = BlockID {
hash: B256::from([0; 32]),
number: 0,
};
let expected = "BlockID { hash: 0x0000000000000000000000000000000000000000000000000000000000000000, number: 0 }";
assert_eq!(block_id.to_string(), expected);
}
}

0 comments on commit 168af3f

Please sign in to comment.