From 1730a5610c85238a743ce09bc69a0ae2329aea9e Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Sun, 17 May 2026 00:06:13 +0530 Subject: [PATCH 1/5] test(wal): add #209 crash-recovery matrix (7 cases) Co-Authored-By: Claude Sonnet 4.6 --- tests/wal_test.rs | 181 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/tests/wal_test.rs b/tests/wal_test.rs index df58304430..b07ac86bcc 100644 --- a/tests/wal_test.rs +++ b/tests/wal_test.rs @@ -533,6 +533,187 @@ fn test_implicit_tx_execute_survives_replay() { ); } +// ══ Wave 3: #209 WAL crash-recovery matrix ════════════════════════════════ + +fn read_wal_bytes(db_path: &std::path::Path) -> Vec { + std::fs::read(wal_path_for(db_path)).unwrap_or_default() +} + +fn write_wal_bytes(db_path: &std::path::Path, bytes: &[u8]) { + std::fs::write(wal_path_for(db_path), bytes).unwrap(); +} + +fn setup_db_with_one_fact() -> (tempfile::TempDir, std::path::PathBuf, Vec) { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + db.execute(r#"(transact [[:e1 :name "Alice"]])"#).unwrap(); + std::mem::forget(db); + } + let wal_bytes = read_wal_bytes(&db_path); + (dir, db_path, wal_bytes) +} + +fn query_names(db_path: &std::path::Path) -> Vec { + let db = minigraf::db::Minigraf::open(db_path).unwrap(); + match db.execute("(query [:find ?n :where [?e :name ?n]])").unwrap() { + minigraf::QueryResult::QueryResults { results, .. } => results + .into_iter() + .flatten() + .filter_map(|v| match v { + minigraf::Value::String(s) => Some(s), + _ => None, + }) + .collect(), + _ => vec![], + } +} + +#[test] +fn wal_recover_truncated_length_header() { + let (_dir, db_path, wal_bytes) = setup_db_with_one_fact(); + assert!(!wal_bytes.is_empty(), "WAL should have content"); + write_wal_bytes(&db_path, &wal_bytes[..wal_bytes.len() / 2]); + let names = query_names(&db_path); + assert_eq!(names.len(), 0, "partial WAL entry must not be applied"); +} + +#[test] +fn wal_recover_truncated_payload() { + let (_dir, db_path, wal_bytes) = setup_db_with_one_fact(); + let truncation_point = (wal_bytes.len() * 3) / 4; + write_wal_bytes(&db_path, &wal_bytes[..truncation_point]); + let names = query_names(&db_path); + assert_eq!(names.len(), 0, "entry with truncated payload must not be applied"); +} + +#[test] +fn wal_recover_bad_checksum_second_entry() { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + db.execute(r#"(transact [[:e1 :name "Alice"]])"#).unwrap(); + db.execute(r#"(transact [[:e2 :name "Bob"]])"#).unwrap(); + std::mem::forget(db); + } + let mut wal_bytes = read_wal_bytes(&db_path); + assert!(wal_bytes.len() > 36, "WAL too short to corrupt"); + let n = wal_bytes.len(); + wal_bytes[n - 4] ^= 0xFF; + wal_bytes[n - 3] ^= 0xFF; + write_wal_bytes(&db_path, &wal_bytes); + let names = query_names(&db_path); + assert_eq!(names.len(), 1, "only the entry before bad checksum should replay"); + assert!(names.contains(&"Alice".to_string()), "Alice should survive"); +} + +#[test] +fn wal_recover_committed_tx_crash_before_checkpoint() { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + let mut tx = db.begin_write().unwrap(); + tx.execute(r#"(transact [[:e1 :name "Charlie"]])"#).unwrap(); + tx.commit().unwrap(); + std::mem::forget(db); + } + let names = query_names(&db_path); + assert_eq!(names.len(), 1, "committed tx must survive crash before checkpoint"); + assert!(names.contains(&"Charlie".to_string()), "Charlie must be present"); +} + +#[test] +fn wal_recover_rollback_crash() { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + let mut tx = db.begin_write().unwrap(); + tx.execute(r#"(transact [[:e1 :name "Dave"]])"#).unwrap(); + tx.rollback(); + std::mem::forget(db); + } + let names = query_names(&db_path); + assert_eq!(names.len(), 0, "rolled-back fact must not appear after crash"); +} + +#[test] +fn wal_recover_multiple_committed_corrupt_tail() { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + db.execute(r#"(transact [[:e1 :name "Eve"]])"#).unwrap(); + db.execute(r#"(transact [[:e2 :name "Frank"]])"#).unwrap(); + std::mem::forget(db); + } + let mut wal_bytes = read_wal_bytes(&db_path); + wal_bytes.extend_from_slice(&[0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00]); + write_wal_bytes(&db_path, &wal_bytes); + let names = query_names(&db_path); + assert_eq!(names.len(), 2, "both valid entries must replay; junk tail is discarded"); +} + +#[test] +fn wal_corrupt_tail_never_applied() { + let dir = tempfile::tempdir().unwrap(); + let db_path = dir.path().join("test.graph"); + { + let db = minigraf::db::Minigraf::open(&db_path).unwrap(); + db.execute(r#"(transact [[:e1 :name "Grace"]])"#).unwrap(); + std::mem::forget(db); + } + let mut wal_bytes = read_wal_bytes(&db_path); + let mut fake_entry: Vec = Vec::new(); + fake_entry.extend_from_slice(&0u32.to_le_bytes()); + fake_entry.extend_from_slice(&999u64.to_le_bytes()); + fake_entry.extend_from_slice(&1000u64.to_le_bytes()); + wal_bytes.extend_from_slice(&fake_entry); + write_wal_bytes(&db_path, &wal_bytes); + let names = query_names(&db_path); + assert!(names.contains(&"Grace".to_string()), "Grace should replay"); + assert_eq!(names.len(), 1, "fake entry must not create phantom facts"); +} + +// ══ Wave 3: #214 lock-leak tests ═════════════════════════════════════════ + +#[test] +fn write_lock_not_leaked_after_rollback() { + let db = minigraf::db::Minigraf::in_memory().unwrap(); + let mut tx1 = db.begin_write().unwrap(); + tx1.execute(r#"(transact [[:e1 :name "Temp"]])"#).unwrap(); + tx1.rollback(); + let mut tx2 = db.begin_write().unwrap(); + tx2.execute(r#"(transact [[:e2 :name "Perm"]])"#).unwrap(); + tx2.commit().unwrap(); + let n = count_results( + db.execute("(query [:find ?n :where [?e :name ?n]])") + .unwrap(), + ); + assert_eq!(n, 1, "only committed fact should be visible"); +} + +#[test] +fn write_state_clean_after_drop() { + let db = minigraf::db::Minigraf::in_memory().unwrap(); + { + let mut tx = db.begin_write().unwrap(); + tx.execute(r#"(transact [[:e1 :name "Ghost"]])"#).unwrap(); + // drop without commit or rollback + } + let mut tx2 = db.begin_write().unwrap(); + tx2.execute(r#"(transact [[:e2 :name "Real"]])"#).unwrap(); + tx2.commit().unwrap(); + let n = count_results( + db.execute("(query [:find ?n :where [?e :name ?n]])") + .unwrap(), + ); + assert_eq!(n, 1, "only committed fact visible after dropped tx"); +} + // ── 12. V2 file upgrades to V3 on checkpoint ───────────────────────────────── /// Create a v2-format `.graph` file manually (version field = 2, no From 28b258f68e031030f69f9696efb09dddd21b4e78 Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Sun, 17 May 2026 00:06:25 +0530 Subject: [PATCH 2/5] test(wal): add #214 fault-injection unit tests (3 cases) Co-Authored-By: Claude Sonnet 4.6 --- src/storage/persistent_facts.rs | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/storage/persistent_facts.rs b/src/storage/persistent_facts.rs index 2f0bfeefd6..f6034d98b5 100644 --- a/src/storage/persistent_facts.rs +++ b/src/storage/persistent_facts.rs @@ -2081,4 +2081,61 @@ mod tests { assert!(!backend.is_new(), "reopened file should not be new"); drop(backend); } + + // ══ Wave 3: #214 fault-injection unit tests ═══════════════════════════ + + mod fault_injection_tests { + use super::*; + use crate::storage::backend::fault_inject::{FaultConfig, FaultInjectingBackend}; + use crate::storage::backend::MemoryBackend; + + fn make_pfs_with_config() -> ( + PersistentFactStorage>, + std::sync::Arc>, + ) { + let (backend, config) = FaultInjectingBackend::with_config(MemoryBackend::new()); + let pfs = PersistentFactStorage::new(backend, 16).unwrap(); + (pfs, config) + } + + fn stage_fact( + pfs: &mut PersistentFactStorage>, + ) { + let entity = Uuid::new_v4(); + pfs.storage() + .transact( + vec![(entity, ":test/attr".to_string(), Value::Boolean(true))], + None, + ) + .unwrap(); + pfs.mark_dirty(); + } + + #[test] + fn save_returns_error_when_write_fails() { + let (mut pfs, config) = make_pfs_with_config(); + stage_fact(&mut pfs); + config.lock().unwrap().fail_write_after = Some(0); + let result = pfs.save(); + assert!(result.is_err(), "save must return Err when write_page fails"); + } + + #[test] + fn save_returns_error_when_sync_fails() { + let (mut pfs, config) = make_pfs_with_config(); + stage_fact(&mut pfs); + config.lock().unwrap().fail_sync_after = Some(0); + let result = pfs.save(); + assert!(result.is_err(), "save must return Err when sync fails"); + } + + #[test] + fn save_error_message_is_non_empty() { + let (mut pfs, config) = make_pfs_with_config(); + stage_fact(&mut pfs); + config.lock().unwrap().fail_sync_after = Some(0); + let err = pfs.save().unwrap_err(); + assert!(!err.to_string().is_empty(), "error message must not be empty"); + } + } } From 0c8d9ba33cc3bf73780ee9825804d1deaf33d9e1 Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Sun, 17 May 2026 00:06:53 +0530 Subject: [PATCH 3/5] test(fuzz): add #210 WAL and file-format fuzz targets with seed corpus Co-Authored-By: Claude Sonnet 4.6 --- fuzz/Cargo.toml | 1 + fuzz/corpus/file_header/seed_bad_magic.bin | Bin 0 -> 4096 bytes fuzz/corpus/file_header/seed_truncated.bin | 1 + fuzz/corpus/file_header/seed_v7.bin | Bin 0 -> 4096 bytes fuzz/corpus/wal_entry/seed_empty.bin | Bin 0 -> 32 bytes fuzz/corpus/wal_entry/seed_truncated.bin | 1 + fuzz/fuzz_targets/btree_page.rs | 17 +++++++++++++++-- fuzz/fuzz_targets/fact_page.rs | 17 +++++++++++++++-- fuzz/fuzz_targets/file_header.rs | 15 +++++++++++++-- fuzz/fuzz_targets/wal_entry.rs | 13 +++++++++++-- 10 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 fuzz/corpus/file_header/seed_bad_magic.bin create mode 100644 fuzz/corpus/file_header/seed_truncated.bin create mode 100644 fuzz/corpus/file_header/seed_v7.bin create mode 100644 fuzz/corpus/wal_entry/seed_empty.bin create mode 100644 fuzz/corpus/wal_entry/seed_truncated.bin diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 156b85c422..a0ae524d90 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -10,6 +10,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" minigraf = { path = ".." } +tempfile = "3" [[bin]] name = "wal_entry" diff --git a/fuzz/corpus/file_header/seed_bad_magic.bin b/fuzz/corpus/file_header/seed_bad_magic.bin new file mode 100644 index 0000000000000000000000000000000000000000..ff64d82a2ae654ac191eb9a7cbaa2f4b1470a35a GIT binary patch literal 4096 rcmeIu0Sy2E48x$ytbZlYwAV0z#I4>|#1 literal 0 HcmV?d00001 diff --git a/fuzz/corpus/file_header/seed_truncated.bin b/fuzz/corpus/file_header/seed_truncated.bin new file mode 100644 index 0000000000..eef4d93485 --- /dev/null +++ b/fuzz/corpus/file_header/seed_truncated.bin @@ -0,0 +1 @@ +MGRF \ No newline at end of file diff --git a/fuzz/corpus/file_header/seed_v7.bin b/fuzz/corpus/file_header/seed_v7.bin new file mode 100644 index 0000000000000000000000000000000000000000..11656340afdaaca7c2f8cd18cdfc8f0d6ad66456 GIT binary patch literal 4096 vcmeIuF%bX&1OPyrW=t0S!|37uBmDGM1_lfmFkrxd0RsjM7%*VKz~_MjKSTjE literal 0 HcmV?d00001 diff --git a/fuzz/corpus/wal_entry/seed_empty.bin b/fuzz/corpus/wal_entry/seed_empty.bin new file mode 100644 index 0000000000000000000000000000000000000000..b6ce01809fab0b156b3d905c2d3662c621893a4f GIT binary patch literal 32 OcmeYbcl2RozzqN-p8+!f literal 0 HcmV?d00001 diff --git a/fuzz/corpus/wal_entry/seed_truncated.bin b/fuzz/corpus/wal_entry/seed_truncated.bin new file mode 100644 index 0000000000..fc9d968d1f --- /dev/null +++ b/fuzz/corpus/wal_entry/seed_truncated.bin @@ -0,0 +1 @@ +MWAL \ No newline at end of file diff --git a/fuzz/fuzz_targets/btree_page.rs b/fuzz/fuzz_targets/btree_page.rs index af778b99a4..c93a26b03a 100644 --- a/fuzz/fuzz_targets/btree_page.rs +++ b/fuzz/fuzz_targets/btree_page.rs @@ -1,6 +1,19 @@ #![no_main] use libfuzzer_sys::fuzz_target; -fuzz_target!(|_data: &[u8]| { - // Stub — implemented in Wave 3 PR 2 +fuzz_target!(|data: &[u8]| { + let dir = match tempfile::tempdir() { + Ok(d) => d, + Err(_) => return, + }; + let path = dir.path().join("fuzz.graph"); + let mut content = vec![0u8; 4096 * 3]; + content[0..4].copy_from_slice(b"MGRF"); + content[4..8].copy_from_slice(&7u32.to_le_bytes()); + let copy_len = data.len().min(4096); + content[4096 * 2..4096 * 2 + copy_len].copy_from_slice(&data[..copy_len]); + if std::fs::write(&path, &content).is_err() { + return; + } + let _ = minigraf::db::Minigraf::open(&path); }); diff --git a/fuzz/fuzz_targets/fact_page.rs b/fuzz/fuzz_targets/fact_page.rs index af778b99a4..c63d38219e 100644 --- a/fuzz/fuzz_targets/fact_page.rs +++ b/fuzz/fuzz_targets/fact_page.rs @@ -1,6 +1,19 @@ #![no_main] use libfuzzer_sys::fuzz_target; -fuzz_target!(|_data: &[u8]| { - // Stub — implemented in Wave 3 PR 2 +fuzz_target!(|data: &[u8]| { + let dir = match tempfile::tempdir() { + Ok(d) => d, + Err(_) => return, + }; + let path = dir.path().join("fuzz.graph"); + let mut content = vec![0u8; 4096 * 2]; + content[0..4].copy_from_slice(b"MGRF"); + content[4..8].copy_from_slice(&7u32.to_le_bytes()); + let copy_len = data.len().min(4096); + content[4096..4096 + copy_len].copy_from_slice(&data[..copy_len]); + if std::fs::write(&path, &content).is_err() { + return; + } + let _ = minigraf::db::Minigraf::open(&path); }); diff --git a/fuzz/fuzz_targets/file_header.rs b/fuzz/fuzz_targets/file_header.rs index af778b99a4..f9e4c0bb03 100644 --- a/fuzz/fuzz_targets/file_header.rs +++ b/fuzz/fuzz_targets/file_header.rs @@ -1,6 +1,17 @@ #![no_main] use libfuzzer_sys::fuzz_target; -fuzz_target!(|_data: &[u8]| { - // Stub — implemented in Wave 3 PR 2 +fuzz_target!(|data: &[u8]| { + let dir = match tempfile::tempdir() { + Ok(d) => d, + Err(_) => return, + }; + let path = dir.path().join("fuzz.graph"); + let mut page = vec![0u8; 4096]; + let copy_len = data.len().min(4096); + page[..copy_len].copy_from_slice(&data[..copy_len]); + if std::fs::write(&path, &page).is_err() { + return; + } + let _ = minigraf::db::Minigraf::open(&path); }); diff --git a/fuzz/fuzz_targets/wal_entry.rs b/fuzz/fuzz_targets/wal_entry.rs index af778b99a4..575c229ed7 100644 --- a/fuzz/fuzz_targets/wal_entry.rs +++ b/fuzz/fuzz_targets/wal_entry.rs @@ -1,6 +1,15 @@ #![no_main] use libfuzzer_sys::fuzz_target; -fuzz_target!(|_data: &[u8]| { - // Stub — implemented in Wave 3 PR 2 +fuzz_target!(|data: &[u8]| { + let dir = match tempfile::tempdir() { + Ok(d) => d, + Err(_) => return, + }; + let db_path = dir.path().join("fuzz.graph"); + let wal_path = dir.path().join("fuzz.graph.wal"); + if std::fs::write(&wal_path, data).is_err() { + return; + } + let _ = minigraf::db::Minigraf::open(&db_path); }); From 39c3c91262012daa19bf0fe0c81d286278c62c08 Mon Sep 17 00:00:00 2001 From: Aditya Mukhopadhyay Date: Sun, 17 May 2026 00:22:22 +0530 Subject: [PATCH 4/5] test(fuzz): add missing seed corpus for fact_page and btree_page targets Co-Authored-By: Claude Sonnet 4.6 --- fuzz/corpus/btree_page/seed_v7_3page.bin | Bin 0 -> 12288 bytes fuzz/corpus/fact_page/seed_v7_2page.bin | Bin 0 -> 8192 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 fuzz/corpus/btree_page/seed_v7_3page.bin create mode 100644 fuzz/corpus/fact_page/seed_v7_2page.bin diff --git a/fuzz/corpus/btree_page/seed_v7_3page.bin b/fuzz/corpus/btree_page/seed_v7_3page.bin new file mode 100644 index 0000000000000000000000000000000000000000..2859689f01977a16daa2a421830d5ac1cd8aedcb GIT binary patch literal 12288 zcmeIuF%AF_00Y2=!Oxg1{{I-nCk)r5?S6Bt-jdYQoAS;QAV7cs0RjXF5FkK+009C7 p2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009CY32d=d0XYBw literal 0 HcmV?d00001 diff --git a/fuzz/corpus/fact_page/seed_v7_2page.bin b/fuzz/corpus/fact_page/seed_v7_2page.bin new file mode 100644 index 0000000000000000000000000000000000000000..6a51f92d6ee27c841308dfb9ec3d327934faa9d5 GIT binary patch literal 8192 zcmeIuu?+wq3 Date: Sun, 17 May 2026 00:28:02 +0530 Subject: [PATCH 5/5] docs: fix swapped issue numbers in Wave 3 PR4 and PR6 plans #219 = coverage gates (not XTDB/Datomic compat) #221 = XTDB/Datomic compat corpus (not proptest) #212 = proptest reference evaluator (not coverage gates) Co-Authored-By: Claude Sonnet 4.6 --- src/storage/persistent_facts.rs | 16 ++++++++----- tests/wal_test.rs | 40 +++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/storage/persistent_facts.rs b/src/storage/persistent_facts.rs index f6034d98b5..cbab1c4a5c 100644 --- a/src/storage/persistent_facts.rs +++ b/src/storage/persistent_facts.rs @@ -2086,8 +2086,8 @@ mod tests { mod fault_injection_tests { use super::*; - use crate::storage::backend::fault_inject::{FaultConfig, FaultInjectingBackend}; use crate::storage::backend::MemoryBackend; + use crate::storage::backend::fault_inject::{FaultConfig, FaultInjectingBackend}; fn make_pfs_with_config() -> ( PersistentFactStorage>, @@ -2098,9 +2098,7 @@ mod tests { (pfs, config) } - fn stage_fact( - pfs: &mut PersistentFactStorage>, - ) { + fn stage_fact(pfs: &mut PersistentFactStorage>) { let entity = Uuid::new_v4(); pfs.storage() .transact( @@ -2117,7 +2115,10 @@ mod tests { stage_fact(&mut pfs); config.lock().unwrap().fail_write_after = Some(0); let result = pfs.save(); - assert!(result.is_err(), "save must return Err when write_page fails"); + assert!( + result.is_err(), + "save must return Err when write_page fails" + ); } #[test] @@ -2135,7 +2136,10 @@ mod tests { stage_fact(&mut pfs); config.lock().unwrap().fail_sync_after = Some(0); let err = pfs.save().unwrap_err(); - assert!(!err.to_string().is_empty(), "error message must not be empty"); + assert!( + !err.to_string().is_empty(), + "error message must not be empty" + ); } } } diff --git a/tests/wal_test.rs b/tests/wal_test.rs index b07ac86bcc..83a5e0205f 100644 --- a/tests/wal_test.rs +++ b/tests/wal_test.rs @@ -557,7 +557,10 @@ fn setup_db_with_one_fact() -> (tempfile::TempDir, std::path::PathBuf, Vec) fn query_names(db_path: &std::path::Path) -> Vec { let db = minigraf::db::Minigraf::open(db_path).unwrap(); - match db.execute("(query [:find ?n :where [?e :name ?n]])").unwrap() { + match db + .execute("(query [:find ?n :where [?e :name ?n]])") + .unwrap() + { minigraf::QueryResult::QueryResults { results, .. } => results .into_iter() .flatten() @@ -585,7 +588,11 @@ fn wal_recover_truncated_payload() { let truncation_point = (wal_bytes.len() * 3) / 4; write_wal_bytes(&db_path, &wal_bytes[..truncation_point]); let names = query_names(&db_path); - assert_eq!(names.len(), 0, "entry with truncated payload must not be applied"); + assert_eq!( + names.len(), + 0, + "entry with truncated payload must not be applied" + ); } #[test] @@ -605,7 +612,11 @@ fn wal_recover_bad_checksum_second_entry() { wal_bytes[n - 3] ^= 0xFF; write_wal_bytes(&db_path, &wal_bytes); let names = query_names(&db_path); - assert_eq!(names.len(), 1, "only the entry before bad checksum should replay"); + assert_eq!( + names.len(), + 1, + "only the entry before bad checksum should replay" + ); assert!(names.contains(&"Alice".to_string()), "Alice should survive"); } @@ -621,8 +632,15 @@ fn wal_recover_committed_tx_crash_before_checkpoint() { std::mem::forget(db); } let names = query_names(&db_path); - assert_eq!(names.len(), 1, "committed tx must survive crash before checkpoint"); - assert!(names.contains(&"Charlie".to_string()), "Charlie must be present"); + assert_eq!( + names.len(), + 1, + "committed tx must survive crash before checkpoint" + ); + assert!( + names.contains(&"Charlie".to_string()), + "Charlie must be present" + ); } #[test] @@ -637,7 +655,11 @@ fn wal_recover_rollback_crash() { std::mem::forget(db); } let names = query_names(&db_path); - assert_eq!(names.len(), 0, "rolled-back fact must not appear after crash"); + assert_eq!( + names.len(), + 0, + "rolled-back fact must not appear after crash" + ); } #[test] @@ -654,7 +676,11 @@ fn wal_recover_multiple_committed_corrupt_tail() { wal_bytes.extend_from_slice(&[0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00]); write_wal_bytes(&db_path, &wal_bytes); let names = query_names(&db_path); - assert_eq!(names.len(), 2, "both valid entries must replay; junk tail is discarded"); + assert_eq!( + names.len(), + 2, + "both valid entries must replay; junk tail is discarded" + ); } #[test]