Skip to content

Commit 0038769

Browse files
committed
test(net): try to find out why it blocks
Remove the channel and wait for the spawned task directly.
1 parent 89bdb86 commit 0038769

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

compio-net/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ libc = { workspace = true }
3939
# Shared dev dependencies for all platforms
4040
[dev-dependencies]
4141
compio-macros = { workspace = true }
42-
futures-channel = { workspace = true }
4342
futures-util = { workspace = true }
4443
tempfile = { workspace = true }

compio-net/tests/tcp_accept.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ use compio_net::{TcpListener, TcpStream, ToSocketAddrsAsync};
33
async fn test_impl(addr: impl ToSocketAddrsAsync) {
44
let listener = TcpListener::bind(addr).await.unwrap();
55
let addr = listener.local_addr().unwrap();
6-
let (tx, rx) = futures_channel::oneshot::channel();
7-
compio_runtime::spawn(async move {
6+
let task = compio_runtime::spawn(async move {
87
let (socket, _) = listener.accept().await.unwrap();
9-
assert!(tx.send(socket).is_ok());
10-
})
11-
.detach();
8+
socket
9+
});
1210
let cli = TcpStream::connect(&addr).await.unwrap();
13-
let srv = rx.await.unwrap();
11+
let srv = task.await;
1412
assert_eq!(cli.local_addr().unwrap(), srv.peer_addr().unwrap());
1513
}
1614

compio-net/tests/tcp_connect.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ async fn test_connect_ip_impl(
1010
let addr = listener.local_addr().unwrap();
1111
assert!(assert_fn(&addr));
1212

13-
let (tx, rx) = futures_channel::oneshot::channel();
14-
15-
compio_runtime::spawn(async move {
13+
let task = compio_runtime::spawn(async move {
1614
let (socket, addr) = listener.accept().await.unwrap();
1715
assert_eq!(addr, socket.peer_addr().unwrap());
18-
assert!(tx.send(socket).is_ok());
19-
})
20-
.detach();
16+
socket
17+
});
2118

2219
let mine = TcpStream::connect(&addr).await.unwrap();
23-
let theirs = rx.await.unwrap();
20+
let theirs = task.await;
2421

2522
assert_eq!(mine.local_addr().unwrap(), theirs.peer_addr().unwrap());
2623
assert_eq!(theirs.local_addr().unwrap(), mine.peer_addr().unwrap());

0 commit comments

Comments
 (0)