clearer assertions in sparse_path tests
This commit is contained in:
parent
e5950497f5
commit
2df454c855
1 changed files with 12 additions and 5 deletions
|
@ -283,7 +283,10 @@ impl Iterator for SparseMerklePathIter<'_> {
|
|||
self.next_depth = this_depth.get() - 1;
|
||||
|
||||
// `this_depth` is only ever decreasing, so it can't ever exceed `self.path.depth()`.
|
||||
let node = self.path.at_depth(this_depth).expect("current depth should never exceed the path depth");
|
||||
let node = self
|
||||
.path
|
||||
.at_depth(this_depth)
|
||||
.expect("current depth should never exceed the path depth");
|
||||
Some(node)
|
||||
}
|
||||
|
||||
|
@ -709,16 +712,20 @@ mod tests {
|
|||
let index = NodeIndex::from(Smt::key_to_leaf_index(key));
|
||||
|
||||
let control_path = tree.get_path(key);
|
||||
for (&control_node, proof_index) in iter::zip(&*control_path, index.proof_indices()) {
|
||||
for (i, (&control_node, proof_index)) in
|
||||
iter::zip(&*control_path, index.proof_indices()).enumerate()
|
||||
{
|
||||
let proof_node = tree.get_hash(proof_index);
|
||||
assert_eq!(control_node, proof_node, "WHat");
|
||||
assert_eq!(control_node, proof_node, "on iteration {i}");
|
||||
}
|
||||
|
||||
let sparse_path =
|
||||
SparseMerklePath::from_sized_iter(control_path.clone().into_iter()).unwrap();
|
||||
for (sparse_node, proof_idx) in iter::zip(sparse_path.clone(), index.proof_indices()) {
|
||||
for (i, (sparse_node, proof_idx)) in
|
||||
iter::zip(sparse_path.clone(), index.proof_indices()).enumerate()
|
||||
{
|
||||
let proof_node = tree.get_hash(proof_idx);
|
||||
assert_eq!(sparse_node, proof_node, "WHat");
|
||||
assert_eq!(sparse_node, proof_node, "on iteration {i}");
|
||||
}
|
||||
|
||||
assert_eq!(control_path.depth(), sparse_path.depth());
|
||||
|
|
Loading…
Add table
Reference in a new issue