Skip to content

Commit 874597b

Browse files
authored
Fix the roundtrip test (#3710)
## Description Since the server was actively closing the connection it is possible that the client would not have read the response yet by the time the connection is closed. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist <!-- Remove any that are not relevant. --> - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. - [ ] List all breaking changes in the above "Breaking Changes" section. - [ ] Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are: - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc) - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip) - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs) - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe) - [ ] [`sendme`](https://github.com/n0-computer/sendme) <!-- Message of single commit: -->
1 parent 3f4d365 commit 874597b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

iroh/src/magicsock.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,6 @@ mod tests {
16191619

16201620
let stats = conn.stats();
16211621
info!("stats: {:#?}", stats);
1622-
// TODO: ensure panics in this function are reported ok
16231622
if matches!(loss, ExpectedLoss::AlmostNone) {
16241623
for info in conn.paths().get().iter() {
16251624
assert!(
@@ -1630,10 +1629,10 @@ mod tests {
16301629
}
16311630
}
16321631

1633-
info!("close");
1634-
conn.close(0u32.into(), b"done");
1635-
info!("wait idle");
1632+
conn.closed().await;
1633+
info!("closed");
16361634
ep.endpoint().wait_idle().await;
1635+
info!("idle");
16371636

16381637
Ok(())
16391638
}
@@ -1684,10 +1683,10 @@ mod tests {
16841683
}
16851684
}
16861685

1687-
info!("close");
16881686
conn.close(0u32.into(), b"done");
1689-
info!("wait idle");
1687+
info!("closed");
16901688
ep.endpoint().wait_idle().await;
1689+
info!("idle");
16911690
Ok(())
16921691
}
16931692

@@ -1708,26 +1707,26 @@ mod tests {
17081707
let recv_endpoint_id = receiver.id();
17091708
info!("\nroundtrip: {send_endpoint_id:#} -> {recv_endpoint_id:#}");
17101709

1711-
let receiver_task = tokio::spawn(echo_receiver(receiver, loss));
1710+
let receiver_task = AbortOnDropHandle::new(tokio::spawn(echo_receiver(receiver, loss)));
17121711
let sender_res = echo_sender(sender, recv_endpoint_id, payload, loss).await;
17131712
let sender_is_err = match sender_res {
17141713
Ok(()) => false,
17151714
Err(err) => {
1716-
eprintln!("[sender] Error:\n{err:#?}");
1715+
error!("[sender] Error:\n{err:#?}");
17171716
true
17181717
}
17191718
};
17201719
let receiver_is_err = match receiver_task.await {
17211720
Ok(Ok(())) => false,
17221721
Ok(Err(err)) => {
1723-
eprintln!("[receiver] Error:\n{err:#?}");
1722+
error!("[receiver] Error:\n{err:#?}");
17241723
true
17251724
}
17261725
Err(joinerr) => {
17271726
if joinerr.is_panic() {
17281727
std::panic::resume_unwind(joinerr.into_panic());
17291728
} else {
1730-
eprintln!("[receiver] Error:\n{joinerr:#?}");
1729+
error!("[receiver] Error:\n{joinerr:#?}");
17311730
}
17321731
true
17331732
}
@@ -1801,6 +1800,7 @@ mod tests {
18011800
rng.fill_bytes(&mut data);
18021801
run_roundtrip(m1.clone(), m2.clone(), &data, ExpectedLoss::AlmostNone).await;
18031802
run_roundtrip(m2.clone(), m1.clone(), &data, ExpectedLoss::AlmostNone).await;
1803+
info!("\n-- round {i} finished");
18041804
}
18051805

18061806
Ok(())

0 commit comments

Comments
 (0)