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

Function flush_threshold_ops

nodedb/src/control/surrogate/registry.rs:353–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351
352 #[test]
353 fn flush_threshold_ops() {
354 let reg = SurrogateRegistry::new();
355 assert!(!reg.should_flush(), "fresh registry should not flush yet");
356 for _ in 0..(FLUSH_OPS_THRESHOLD - 1) {
357 let _ = reg.alloc_one().unwrap();
358 }
359 assert!(!reg.should_flush(), "below ops threshold should not flush");
360 let _ = reg.alloc_one().unwrap();
361 assert!(reg.should_flush(), "at ops threshold should flush");
362
363 let persist = MemPersist::new();
364 reg.flush(&persist).unwrap();
365 assert_eq!(persist.calls(), 1);
366 assert_eq!(persist.last(), Some(FLUSH_OPS_THRESHOLD as u32));
367 assert!(!reg.should_flush(), "post-flush should clear ops");
368 }
369
370 #[test]
371 fn flush_threshold_elapsed() {

Callers

nothing calls this directly

Calls 2

alloc_oneMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected