shardtree: Turn `LocatedPrunableTree::from_iter` test failure into panic

The logic in `LocatedPrunableTree::from_iter` is violating an invariant
of the `unite` helper function. The new assertion prevents an invalid
tree state from being returned.
This commit is contained in:
Jack Grigg 2023-07-06 12:57:46 +00:00
parent b325399f0d
commit bddf6684e3
1 changed files with 1 additions and 1 deletions

View File

@ -890,6 +890,7 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
rroot: LocatedPrunableTree<H>,
prune_below: Level,
) -> LocatedTree<Option<Rc<H>>, (H, RetentionFlags)> {
assert_eq!(lroot.root_addr.parent(), rroot.root_addr.parent());
LocatedTree {
root_addr: lroot.root_addr.parent(),
root: if lroot.root_addr.level() < prune_below {
@ -994,7 +995,6 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
);
}
// at this point, prev_tree.level == next_tree.level
Some(unite(prev_tree, next_tree, prune_below))
} else {
Some(next_tree)