diff --git a/crates/voelin-core/src/link/tests.rs b/crates/voelin-core/src/link/tests.rs index 90f8c77..5d71f0a 100644 --- a/crates/voelin-core/src/link/tests.rs +++ b/crates/voelin-core/src/link/tests.rs @@ -598,15 +598,20 @@ async fn a_file_is_downloaded_through_the_connection_the_link_opens() { report, }); let LinkCmd::OpenRead { reply, .. } = rig.inner_cmd().await else { panic!("a connection") }; - // A file whose bytes do not come: the transfer waits in the middle. + // A file whose bytes do not come: the transfer waits in the middle, with + // its part file made. `Started` is reported just before the part file is + // opened, and a cancel in between would find nothing to remove while the + // open still goes on, so the part file is what is waited for. let (server, client) = tokio::io::duplex(64); let _ = reply.send(Ok((1 << 20, Box::pin(client)))); for _ in 0..500 { - if states.lock().unwrap().iter().any(|s| matches!(s, TransferState::Started { .. })) { + if part.exists() { break; } tokio::time::sleep(Duration::from_millis(10)).await; } + assert!(part.exists(), "the transfer made its part file: {:?}", states.lock().unwrap()); + assert!(states.lock().unwrap().iter().any(|s| matches!(s, TransferState::Started { .. }))); rig.give(LinkCmd::CancelTransfer(3)); assert_eq!(final_state(&states).await, TransferState::Cancelled); rig.quiet();