MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / replay_after_close

Function replay_after_close

nodedb-wal/src/segmented.rs:363–387  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

361
362 #[test]
363 fn replay_after_close() {
364 let dir = tempfile::tempdir().unwrap();
365 let wal_dir = dir.path().join("wal");
366
367 // Write records.
368 {
369 let mut wal = SegmentedWal::open(test_config(&wal_dir)).unwrap();
370 wal.append(RecordType::Put as u32, 1, 0, 0, b"first")
371 .unwrap();
372 wal.append(RecordType::Delete as u32, 2, 1, 0, b"second")
373 .unwrap();
374 wal.append(RecordType::Put as u32, 1, 0, 0, b"third")
375 .unwrap();
376 wal.sync().unwrap();
377 }
378
379 // Reopen and replay.
380 let wal = SegmentedWal::open(test_config(&wal_dir)).unwrap();
381 let records = wal.replay().unwrap();
382 assert_eq!(records.len(), 3);
383 assert_eq!(records[0].payload, b"first");
384 assert_eq!(records[1].payload, b"second");
385 assert_eq!(records[2].payload, b"third");
386 assert_eq!(wal.next_lsn(), 4);
387 }
388
389 #[test]
390 fn automatic_segment_rollover() {

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
test_configFunction · 0.70
openFunction · 0.50
pathMethod · 0.45
appendMethod · 0.45
syncMethod · 0.45
replayMethod · 0.45

Tested by

no test coverage detected