From 1d27855db7be4dd3fdfa5c6777c515033c2b482b Mon Sep 17 00:00:00 2001 From: ltitanb <163874448+ltitanb@users.noreply.github.com> Date: Fri, 16 May 2025 14:23:11 +0100 Subject: [PATCH] impl from hash256 for `ExecutionBlockHash` (#7369) ref: #7367 Implement `From` for `ExecutionBlockHash --- consensus/types/src/execution_block_hash.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/consensus/types/src/execution_block_hash.rs b/consensus/types/src/execution_block_hash.rs index 677b3d3408..6c031f6899 100644 --- a/consensus/types/src/execution_block_hash.rs +++ b/consensus/types/src/execution_block_hash.rs @@ -112,3 +112,22 @@ impl fmt::Display for ExecutionBlockHash { write!(f, "{}", self.0) } } + +impl From for ExecutionBlockHash { + fn from(hash: Hash256) -> Self { + Self(hash) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_from_hash256() { + let hash = Hash256::random(); + let ex_hash = ExecutionBlockHash::from(hash); + + assert_eq!(ExecutionBlockHash(hash), ex_hash); + } +}