Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

feat(primitives): Block Arbitrary Impl #8

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}