From 7479d7fca78a2ad28e6a7672dc5dd0fd8e1d4ddf Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 7 Nov 2026 10:53:44 +0100 Subject: [PATCH] review classifier: pin that a try-out's expiry follows its own size The expiry test only built entries sized for ten classifications, so a run whose deadline was ignored or fixed at the default would pass. It now checks that a run of a hundred is still held when ten would have expired, and drops at its own deadline. --- swarm-controller/src/review_classifier.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/swarm-controller/src/review_classifier.rs b/swarm-controller/src/review_classifier.rs index 11ce0da6..80436e96 100644 --- a/swarm-controller/src/review_classifier.rs +++ b/swarm-controller/src/review_classifier.rs @@ -1279,19 +1279,27 @@ pub(crate) mod tests { #[test] fn a_result_expires_after_its_ttl() { let now = Instant::now(); - let entry = |settled: Option| Entry { + let sized = |classifications: usize, settled: Option| Entry { status: TryOutStatus::settled("abc".to_owned(), done()), started: now, - deadline: run_deadline(10), + deadline: run_deadline(classifications), settled, }; + let entry = |settled: Option| sized(10, settled); let deadline = run_deadline(10); assert!(!entry(Some(now)).expired(now + RESULT_TTL)); assert!(entry(Some(now)).expired(now + RESULT_TTL + Duration::from_secs(1))); - // A run whose reply never came stays until the latest it could have, - // which is later for a bigger run. + // A run whose reply never came stays until the latest it could have. assert!(!entry(None).expired(now + deadline + RESULT_TTL)); assert!(entry(None).expired(now + deadline + RESULT_TTL + Duration::from_secs(1))); + // That is later for a bigger run: a hundred classifications are still + // running when ten would have given up, and expire at their own. + let big = run_deadline(100); + assert!(big > deadline); + let past_ten = now + deadline + RESULT_TTL + Duration::from_secs(1); + assert!(!sized(100, None).expired(past_ten)); + assert!(!sized(100, None).expired(now + big + RESULT_TTL)); + assert!(sized(100, None).expired(now + big + RESULT_TTL + Duration::from_secs(1))); } /// A rules file holding `classifications`, and `extra` beside them.