()
| 73 | /// Ops at or above the frontier survive. |
| 74 | #[test] |
| 75 | fn 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] |
nothing calls this directly
no test coverage detected