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

Function gc_collapses_ops_below_frontier

nodedb/tests/array_sync_gc.rs:75–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73/// Ops at or above the frontier survive.
74#[test]
75fn gc_collapses_ops_below_frontier() {
76 let log = InMemoryOpLog::new();
77 for ms in [10u64, 20, 30, 40] {
78 log.append(&make_op("arr", ms, 1)).expect("append");
79 }
80
81 let mut acks = AckVector::new();
82 acks.record(rep(1), hlc(25, 1)); // frontier = 25
83
84 let sink = MockSnapshotSink::new();
85 let report = collapse_below(&log, &acks, &sink, |array, frontier| {
86 Ok(Some(dummy_snapshot(array, frontier)))
87 })
88 .expect("collapse_below");
89
90 // Ops strictly < 25: ms=10, ms=20 → 2 ops dropped.
91 assert_eq!(report.frontier, hlc(25, 1));
92 assert_eq!(
93 report.ops_dropped, 2,
94 "ops at ms=10 and ms=20 must be dropped"
95 );
96 assert_eq!(
97 report.snapshots_written, 1,
98 "one snapshot written for 'arr'"
99 );
100 assert_eq!(log.len().expect("len"), 2, "ms=30 and ms=40 must remain");
101}
102
103/// Multiple acks from different replicas: the frontier is the minimum.
104#[test]

Callers

nothing calls this directly

Calls 8

repFunction · 0.85
collapse_belowFunction · 0.85
make_opFunction · 0.70
dummy_snapshotFunction · 0.70
hlcFunction · 0.50
expectMethod · 0.45
appendMethod · 0.45
recordMethod · 0.45

Tested by

no test coverage detected