diff --git a/tests/seqno_recovery.rs b/tests/seqno_recovery.rs index ff3a561..e956e62 100644 --- a/tests/seqno_recovery.rs +++ b/tests/seqno_recovery.rs @@ -66,3 +66,47 @@ fn recover_seqno() -> fjall::Result<()> { Ok(()) } + +#[test] +fn recover_seqno_tombstone() -> fjall::Result<()> { + let folder = tempfile::tempdir()?; + + let mut seqno = 0; + + // NOTE: clippy bug + #[allow(unused_assignments)] + { + let keyspace = Config::new(&folder).open()?; + + let partitions = &[ + keyspace.open_partition("default1", PartitionCreateOptions::default())?, + keyspace.open_partition("default2", PartitionCreateOptions::default())?, + keyspace.open_partition("default3", PartitionCreateOptions::default())?, + ]; + + for tree in partitions { + for x in 0..ITEM_COUNT as u64 { + let key = x.to_be_bytes(); + tree.remove(key)?; + + seqno += 1; + assert_eq!(seqno, keyspace.instant()); + } + + for x in 0..ITEM_COUNT as u64 { + let key: [u8; 8] = (x + ITEM_COUNT as u64).to_be_bytes(); + tree.remove(key)?; + + seqno += 1; + assert_eq!(seqno, keyspace.instant()); + } + } + } + + for _ in 0..10 { + let keyspace = Config::new(&folder).open()?; + assert_eq!(seqno, keyspace.instant()); + } + + Ok(()) +}