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

Function snapshot_compaction

nodedb-raft/src/log.rs:236–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234
235 #[test]
236 fn snapshot_compaction() {
237 let mut log = RaftLog::new(MemStorage::new());
238 for i in 1..=10 {
239 log.append(make_entry(1, i)).unwrap();
240 }
241
242 log.apply_snapshot(5, 1);
243 assert_eq!(log.snapshot_index(), 5);
244 assert_eq!(log.last_index(), 10);
245 // Compacted entries are gone.
246 assert!(log.entry_at(3).is_none());
247 assert!(log.entry_at(5).is_none()); // snapshot boundary
248 assert!(log.entry_at(6).is_some());
249
250 // Range query into compacted region fails.
251 assert!(log.entries_range(3, 8).is_err());
252 }
253}

Callers

nothing calls this directly

Calls 3

apply_snapshotMethod · 0.80
make_entryFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected