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

Function gc_collapses_below_min_ack

nodedb-array/src/sync/gc.rs:210–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208
209 #[test]
210 fn gc_collapses_below_min_ack() {
211 let log = InMemoryOpLog::new();
212 for ms in [10, 20, 30, 40] {
213 log.append(&make_op("arr", ms)).unwrap();
214 }
215 let mut acks = AckVector::new();
216 acks.record(replica(), hlc(25));
217
218 let sink = MockSnapshotSink::new();
219 let report = collapse_below(&log, &acks, &sink, |array, frontier| {
220 Ok(Some(dummy_snapshot(array, frontier)))
221 })
222 .unwrap();
223
224 // frontier = 25; ops at 10 and 20 are below it
225 assert_eq!(report.frontier, hlc(25));
226 assert_eq!(report.ops_dropped, 2);
227 // One distinct array ("arr") had ops below frontier
228 assert_eq!(report.snapshots_written, 1);
229 assert_eq!(sink.snapshot_count(), 1);
230 // Remaining ops: ms=25 (excluded by strict <), ms=30, ms=40
231 // drop_below(25) drops strictly < 25 → drops 10, 20 → 2 remain (30 and 40)
232 assert_eq!(log.len().unwrap(), 2);
233 }
234
235 #[test]
236 fn gc_skips_arrays_with_no_live_state() {

Callers

nothing calls this directly

Calls 7

collapse_belowFunction · 0.85
make_opFunction · 0.70
replicaFunction · 0.70
hlcFunction · 0.70
dummy_snapshotFunction · 0.70
appendMethod · 0.45
recordMethod · 0.45

Tested by

no test coverage detected