shardtree: Add test exposing `PrunableTree::merge_checked` bug

This commit is contained in:
Jack Grigg 2023-07-05 21:40:42 +00:00
parent 1be68e5c64
commit 2ef96ba4ba
1 changed files with 20 additions and 0 deletions

View File

@ -1535,6 +1535,26 @@ mod tests {
);
}
#[test]
fn merge_checked_flags() {
let t0: PrunableTree<String> = leaf(("a".to_string(), RetentionFlags::EPHEMERAL));
let t1: PrunableTree<String> = leaf(("a".to_string(), RetentionFlags::MARKED));
let t2: PrunableTree<String> = leaf(("a".to_string(), RetentionFlags::CHECKPOINT));
assert_eq!(
t0.merge_checked(Address::from_parts(1.into(), 0), t1.clone()),
Ok(t1.clone()),
);
assert_eq!(
t1.merge_checked(Address::from_parts(1.into(), 0), t2),
Ok(leaf((
"a".to_string(),
RetentionFlags::MARKED | RetentionFlags::CHECKPOINT,
))),
);
}
#[test]
fn located_insert_subtree() {
let t: LocatedPrunableTree<String> = LocatedTree {