Skip to content

Commit 4decfbd

Browse files
futurepaulclaude
andcommitted
simplex tests: a file is overdue counted from its forward, however long that took
The batch tests' clock started before their forwards and allowed 1 s for them, but forward stamps each file with the real clock and writes the link's file each time. On a slow runner a batch of 32 took longer, so the later files were not yet overdue, stayed in `files`, and FILES_MAX turned away as many of the next batch: 43 of 64 cancels kept (#779's images check). The tests now take an instant past the wait for every file forwarded so far (`all_overdue`), wherever they relied on that second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7db3cfd commit 4decfbd

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

  • images/bridge/src/simplex

‎images/bridge/src/simplex/run.rs‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ mod tests {
22302230
let p8 = posts.try_recv().expect("8 posted");
22312231
assert!(p8.inbound.item == 8 && p8.file.is_some() && p8.note.is_none());
22322232
// 7 never does: cancelled at the core, posted once with a note
2233-
m.files_overdue(t0 + Duration::from_millis(FILE_WAIT_MS + 1_000));
2233+
m.files_overdue(all_overdue(t0));
22342234
assert!(m.slots[f].files.is_empty());
22352235
assert_eq!(cmds(&mut sent), ["/fcancel 7"]);
22362236
let p7 = posts.try_recv().expect("7 posted");
@@ -2269,6 +2269,13 @@ mod tests {
22692269
Inbound { id: format!("m{item}"), kind: "voice".into(), text: String::new(), at: "2026-10-25T17:00:00Z".into(), item, file: Some(wire::FileRef { id: item, name: "voice.m4a".into(), size: 9_000, path: path.map(str::to_string) }) }
22702270
}
22712271

2272+
/// An instant past `FILE_WAIT_MS` for every file forwarded so far, and
2273+
/// no earlier than `after`: a file's wait counts from its forward, on
2274+
/// the real clock, however long the forwards took (a write each).
2275+
fn all_overdue(after: Instant) -> Instant {
2276+
after.max(Instant::now()) + Duration::from_millis(FILE_WAIT_MS)
2277+
}
2278+
22722279
/// The core's commands sent so far: (corrId, line).
22732280
fn sent_lines(sent: &mut mpsc::Receiver<String>) -> Vec<(String, String)> {
22742281
std::iter::from_fn(|| sent.try_recv().ok())
@@ -2421,7 +2428,7 @@ mod tests {
24212428
// given up on, then done anyway: deleted; its catch-up posts the note
24222429
let t0 = Instant::now();
24232430
m.forward(f, voice(7, None));
2424-
m.files_overdue(t0 + Duration::from_millis(FILE_WAIT_MS + 1_000));
2431+
m.files_overdue(all_overdue(t0));
24252432
assert!(posts.try_recv().is_ok_and(|p| p.inbound.item == 7 && p.note.is_some()));
24262433
std::fs::write(files.join("voice_7.m4a"), b"late").expect("a file");
24272434
m.file_event(f, &Resp::FileDone { file: 7, path: "voice_7.m4a".into() });
@@ -2669,7 +2676,7 @@ mod tests {
26692676
drop(sent_lines(&mut sent));
26702677
let core = m.slots.get_mut(f).expect("its slot").core.take();
26712678
m.slots.get_mut(f).expect("its slot").up = false;
2672-
t += Duration::from_millis(FILE_WAIT_MS + 1_000);
2679+
t = all_overdue(t);
26732680
m.files_overdue(t);
26742681
assert!(posts.try_recv().is_ok_and(|p| p.inbound.item == 7 && p.note.is_some()), "its note, once");
26752682
assert_eq!(m.slots[f].saved.abandoned.get(&7), Some(&Abandoned::Cancelling));
@@ -2732,7 +2739,7 @@ mod tests {
27322739
for id in &batch {
27332740
m.forward(f, voice(*id, None));
27342741
}
2735-
t += Duration::from_millis(FILE_WAIT_MS + 1_000);
2742+
t = all_overdue(t);
27362743
m.files_overdue(t);
27372744
for (corr, line) in sent_lines(&mut sent) {
27382745
if line.starts_with("/fcancel") {
@@ -2790,7 +2797,7 @@ mod tests {
27902797
for id in &batch {
27912798
m.forward(f, voice(*id, None));
27922799
}
2793-
t += Duration::from_millis(FILE_WAIT_MS + 1_000);
2800+
t = all_overdue(t);
27942801
m.files_overdue(t);
27952802
for (corr, line) in sent_lines(&mut sent) {
27962803
if line.starts_with("/fcancel") {

0 commit comments

Comments
 (0)