Skip to content

Commit

Permalink
fix(mpt): Empty list walker (#493)
Browse files Browse the repository at this point in the history
Co-authored-by: Rami Khalil <[email protected]>
  • Loading branch information
clabby and hashcashier authored Sep 5, 2024
1 parent 67e5d0a commit 933a5f0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/mpt/src/list_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ where
node => Ok(Self::fetch_leaves(node, fetcher)?),
}
}
TrieNode::Empty => Ok(VecDeque::new()),
_ => anyhow::bail!("Invalid trie node type encountered"),
}
}
Expand Down Expand Up @@ -161,6 +162,7 @@ mod test {
get_live_derivable_receipts_list, get_live_derivable_transactions_list,
TrieNodeProvider,
},
NoopTrieDBFetcher,
};
use alloc::{collections::BTreeMap, string::String, vec::Vec};
use alloy_consensus::{ReceiptEnvelope, TxEnvelope};
Expand Down Expand Up @@ -221,4 +223,11 @@ mod test {
VALUES
);
}

#[test]
fn test_empty_list_walker() {
assert!(OrderedListWalker::fetch_leaves(&TrieNode::Empty, &NoopTrieDBFetcher)
.expect("Failed to traverse empty trie")
.is_empty());
}
}

0 comments on commit 933a5f0

Please sign in to comment.