Skip to content

Commit 1d27855

Browse files
authored
impl from hash256 for ExecutionBlockHash (#7369)
ref: #7367 Implement `From<Hash256>` for `ExecutionBlockHash
1 parent b051a5d commit 1d27855

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

consensus/types/src/execution_block_hash.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,22 @@ impl fmt::Display for ExecutionBlockHash {
112112
write!(f, "{}", self.0)
113113
}
114114
}
115+
116+
impl From<Hash256> for ExecutionBlockHash {
117+
fn from(hash: Hash256) -> Self {
118+
Self(hash)
119+
}
120+
}
121+
122+
#[cfg(test)]
123+
mod tests {
124+
use super::*;
125+
126+
#[test]
127+
fn test_from_hash256() {
128+
let hash = Hash256::random();
129+
let ex_hash = ExecutionBlockHash::from(hash);
130+
131+
assert_eq!(ExecutionBlockHash(hash), ex_hash);
132+
}
133+
}

0 commit comments

Comments
 (0)