Skip to content

Commit 1f2db9f

Browse files
authored
fix test by calling stream.finish() (#3665)
1 parent 13fe787 commit 1f2db9f

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

iroh/src/endpoint.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,7 @@ mod tests {
18631863

18641864
info!(me = %ep.id().fmt_short(), "client connecting");
18651865
let conn = ep.connect(dst, TEST_ALPN).await?;
1866+
info!(me = %ep.id().fmt_short(), "client connected");
18661867

18671868
// We should be connected via IP, because it is faster than the relay server.
18681869
// TODO: Maybe not panic if this is not true?
@@ -1875,6 +1876,7 @@ mod tests {
18751876
while let Some(infos) = paths.next().await {
18761877
info!(?infos, "new PathInfos");
18771878
if infos.iter().any(|info| info.is_relay()) {
1879+
info!("client has a relay path");
18781880
break;
18791881
}
18801882
}
@@ -1911,6 +1913,7 @@ mod tests {
19111913

19121914
info!(me = %ep.id().fmt_short(), "server starting");
19131915
let conn = ep.accept().await.anyerr()?.await.anyerr()?;
1916+
info!(me = %ep.id().fmt_short(), "server accepted connection");
19141917

19151918
// Wait for a relay connection to be added. Client does all the asserting here,
19161919
// we just want to wait so we get to see all the mechanics of the connection
@@ -1920,6 +1923,7 @@ mod tests {
19201923
while let Some(infos) = paths.next().await {
19211924
info!(?infos, "new PathInfos");
19221925
if infos.iter().any(|path| path.is_relay()) {
1926+
info!("server has a relay path");
19231927
break;
19241928
}
19251929
}
@@ -1929,6 +1933,8 @@ mod tests {
19291933

19301934
let mut stream = conn.open_uni().await.anyerr()?;
19311935
stream.write_all(b"have relay").await.anyerr()?;
1936+
stream.finish().anyerr()?;
1937+
info!("waiting conn.closed()");
19321938

19331939
Ok(conn.closed().await)
19341940
}

iroh/src/endpoint/connection.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ mod tests {
15211521
use n0_future::StreamExt;
15221522
use n0_watcher::Watcher;
15231523
use rand::SeedableRng;
1524-
use tracing::{Instrument, error_span, info_span, trace_span};
1524+
use tracing::{Instrument, error_span, info, info_span, trace_span};
15251525
use tracing_test::traced_test;
15261526

15271527
use super::Endpoint;
@@ -1740,8 +1740,8 @@ mod tests {
17401740
}
17411741

17421742
#[tokio::test]
1743+
#[traced_test]
17431744
async fn test_paths_watcher() -> Result {
1744-
tracing_subscriber::fmt::init();
17451745
const ALPN: &[u8] = b"test";
17461746
let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0u64);
17471747
let (relay_map, _relay_map, _guard) = run_relay_server().await?;
@@ -1760,13 +1760,13 @@ mod tests {
17601760

17611761
server.online().await;
17621762
let server_addr = server.addr();
1763-
tracing::info!("server addr: {server_addr:?}");
1763+
info!("server addr: {server_addr:?}");
17641764

17651765
let (conn_client, conn_server) = tokio::join!(
17661766
async { client.connect(server_addr, ALPN).await.unwrap() },
17671767
async { server.accept().await.unwrap().await.unwrap() }
17681768
);
1769-
tracing::info!("connected");
1769+
info!("connected");
17701770
let mut paths_client = conn_client.paths().stream();
17711771
let mut paths_server = conn_server.paths().stream();
17721772

@@ -1778,12 +1778,12 @@ mod tests {
17781778
) {
17791779
loop {
17801780
let paths = stream.next().await.expect("paths stream ended");
1781-
tracing::info!(?paths, "paths");
1781+
info!(?paths, "paths");
17821782
if paths.len() >= 2
17831783
&& paths.iter().any(PathInfo::is_relay)
17841784
&& paths.iter().any(PathInfo::is_ip)
17851785
{
1786-
tracing::info!("break");
1786+
info!("break");
17871787
return;
17881788
}
17891789
}
@@ -1806,7 +1806,7 @@ mod tests {
18061806
);
18071807

18081808
// Close the client connection.
1809-
tracing::info!("close client conn");
1809+
info!("close client conn");
18101810
conn_client.close(0u32.into(), b"");
18111811

18121812
// Verify that the path watch streams close.

iroh/src/magicsock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,11 +2307,11 @@ mod tests {
23072307
#[traced_test]
23082308
async fn test_two_devices_setup_teardown() -> Result {
23092309
for i in 0..10 {
2310-
println!("-- round {i}");
2311-
println!("setting up magic stack");
2310+
info!("-- round {i}");
2311+
info!("setting up magic stack");
23122312
let (_guard, m1, m2) = endpoint_pair().await;
23132313

2314-
println!("closing endpoints");
2314+
info!("closing endpoints");
23152315
let msock1 = m1.magic_sock();
23162316
let msock2 = m2.magic_sock();
23172317
m1.close().await;

0 commit comments

Comments
 (0)