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

Function gc_min_ack_with_two_replicas

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

Source from the content-addressed store, hash-verified

279
280 #[test]
281 fn gc_min_ack_with_two_replicas() {
282 let log = InMemoryOpLog::new();
283 for ms in [10, 20, 30, 40] {
284 log.append(&make_op("arr", ms)).unwrap();
285 }
286
287 let r2 = ReplicaId::new(2);
288 let mut acks = AckVector::new();
289 acks.record(replica(), hlc(50)); // replica 1 ack at 50
290 acks.record(r2, hlc(30)); // replica 2 ack at 30 → frontier = 30
291
292 let sink = MockSnapshotSink::new();
293 let report = collapse_below(&log, &acks, &sink, |array, frontier| {
294 Ok(Some(dummy_snapshot(array, frontier)))
295 })
296 .unwrap();
297
298 assert_eq!(report.frontier, hlc(30));
299 // Ops at 10, 20 are strictly < 30 → 2 dropped; 30, 40 survive.
300 assert_eq!(report.ops_dropped, 2);
301 assert_eq!(log.len().unwrap(), 2);
302 }
303}

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