Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nomt/src/beatree/ops/update/leaf_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ fn filter_leaves_changeset(leaf_changeset: &mut Vec<(Key, Option<PageNumber>)>)
// The deleted page was already inserted in the freed_pages, thus,
// now only the inserted page must be kept, resulting in a standard
// modification of the same page, but made by two workers.
for i in 0..leaf_changeset.len() - 1 {
for i in 0..leaf_changeset.len().saturating_sub(1) {
if leaf_changeset[i].0 == leaf_changeset[i + 1].0 {
// PANICS: If two changesets refer to the same page, they
// are expected to be treated as a single one, with one
Expand Down
16 changes: 16 additions & 0 deletions nomt/tests/add_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ fn add_remove_1000() {
assert_eq!(root, expected_roots[10 - i - 1]);
}
}

#[test]
fn delete_missing_key_in_empty_db() {
let mut t = Test::new("delete_missing_key_in_empty_db");
t.write([0; 32], None);
assert_eq!(t.commit().0.into_inner(), Node::default());
}

#[test]
fn delete_missing_key_in_non_empty_db() {
let mut t = Test::new("delete_missing_key_in_non_empty_db");
common::set_balance(&mut t, 0, 1000);
let root = t.commit().0;
common::kill(&mut t, 1);
assert_eq!(t.commit().0, root);
}
Loading