Skip to content

Commit

Permalink
feat: patch-10-17-kona
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Oct 21, 2024
1 parent 4be3cb4 commit 5a88fcf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/mpt/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ impl TrieNode {
}

/// Returns the commitment of a [TrieNode::Blinded] node, if `self` is of the
/// [TrieNode::Blinded] variant.
/// [TrieNode::Blinded] or [TrieNode::Empty] variants.
///
/// ## Returns
/// - `Some(B256)` - The commitment of the blinded node
/// - `None` - `self` is not a [TrieNode::Blinded] node
pub const fn blinded_commitment(&self) -> Option<B256> {
match self {
Self::Blinded { commitment } => Some(*commitment),
Self::Empty => Some(EMPTY_ROOT_HASH),
_ => None,
}
}
Expand Down Expand Up @@ -681,6 +682,12 @@ mod test {
use alloy_trie::{HashBuilder, Nibbles};
use rand::prelude::SliceRandom;

#[test]
fn test_empty_blinded() {
let trie_node = TrieNode::Empty;
assert_eq!(trie_node.blinded_commitment().unwrap(), EMPTY_ROOT_HASH);
}

#[test]
fn test_decode_branch() {
const BRANCH_RLP: [u8; 83] = hex!("f851a0eb08a66a94882454bec899d3e82952dcc918ba4b35a09a84acd98019aef4345080808080808080a05d87a81d9bbf5aee61a6bfeab3a5643347e2c751b36789d988a5b6b163d496518080808080808080");
Expand Down

0 comments on commit 5a88fcf

Please sign in to comment.