diff --git a/iroh/src/magicsock.rs b/iroh/src/magicsock.rs index 209625c542..7c83b7b8b1 100644 --- a/iroh/src/magicsock.rs +++ b/iroh/src/magicsock.rs @@ -1620,7 +1620,6 @@ mod tests { let stats = conn.stats(); info!("stats: {:#?}", stats); - // TODO: ensure panics in this function are reported ok if matches!(loss, ExpectedLoss::AlmostNone) { for info in conn.paths().get().iter() { assert!( @@ -1631,10 +1630,10 @@ mod tests { } } - info!("close"); - conn.close(0u32.into(), b"done"); - info!("wait idle"); + conn.closed().await; + info!("closed"); ep.endpoint().wait_idle().await; + info!("idle"); Ok(()) } @@ -1685,10 +1684,10 @@ mod tests { } } - info!("close"); conn.close(0u32.into(), b"done"); - info!("wait idle"); + info!("closed"); ep.endpoint().wait_idle().await; + info!("idle"); Ok(()) } @@ -1709,26 +1708,26 @@ mod tests { let recv_endpoint_id = receiver.id(); info!("\nroundtrip: {send_endpoint_id:#} -> {recv_endpoint_id:#}"); - let receiver_task = tokio::spawn(echo_receiver(receiver, loss)); + let receiver_task = AbortOnDropHandle::new(tokio::spawn(echo_receiver(receiver, loss))); let sender_res = echo_sender(sender, recv_endpoint_id, payload, loss).await; let sender_is_err = match sender_res { Ok(()) => false, Err(err) => { - eprintln!("[sender] Error:\n{err:#?}"); + error!("[sender] Error:\n{err:#?}"); true } }; let receiver_is_err = match receiver_task.await { Ok(Ok(())) => false, Ok(Err(err)) => { - eprintln!("[receiver] Error:\n{err:#?}"); + error!("[receiver] Error:\n{err:#?}"); true } Err(joinerr) => { if joinerr.is_panic() { std::panic::resume_unwind(joinerr.into_panic()); } else { - eprintln!("[receiver] Error:\n{joinerr:#?}"); + error!("[receiver] Error:\n{joinerr:#?}"); } true } @@ -1802,6 +1801,7 @@ mod tests { rng.fill_bytes(&mut data); run_roundtrip(m1.clone(), m2.clone(), &data, ExpectedLoss::AlmostNone).await; run_roundtrip(m2.clone(), m1.clone(), &data, ExpectedLoss::AlmostNone).await; + info!("\n-- round {i} finished"); } Ok(())