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

Function overflow_drops_oldest

nodedb-bridge/src/telemetry.rs:173–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171
172 #[test]
173 fn overflow_drops_oldest() {
174 let mut ring = TelemetryRing::new(4);
175
176 // Write 6 samples into a capacity-4 ring.
177 for i in 0..6 {
178 ring.record(sample(i, i as u64));
179 }
180
181 assert!(ring.dropped_count() > 0);
182
183 let mut buf = Vec::new();
184 ring.drain_into(&mut buf);
185
186 // Should have the most recent samples, not the oldest.
187 assert!(!buf.is_empty());
188 let last = buf.last().unwrap();
189 assert_eq!(last.metric_id, 5);
190 }
191
192 #[test]
193 fn empty_drain_returns_zero() {

Callers

nothing calls this directly

Calls 4

sampleFunction · 0.70
recordMethod · 0.45
drain_intoMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected