test: bind daemon ports without probe races

This commit is contained in:
NianJiuZst
2026-07-10 23:06:02 +08:00
parent f8907e5f5a
commit 9f82d89788
12 changed files with 12 additions and 48 deletions
+1 -4
View File
@@ -30,7 +30,6 @@ use rand::Rng;
use serde_json::{Value, json};
#[cfg(unix)]
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net::TcpListener;
#[cfg(unix)]
use tokio::net::UnixStream;
use tokio::sync::Mutex;
@@ -53,9 +52,7 @@ fn tempfile_path(prefix: &str) -> PathBuf {
}
async fn spawn_daemon() -> (daemon::DaemonHandle, PathBuf) {
let probe = TcpListener::bind("127.0.0.1:0").await.unwrap();
let port = probe.local_addr().unwrap().port();
drop(probe);
let port = 0;
let sock = tempfile_path("bsk-test-tools-m9");
let handle = daemon::run(DaemonConfig::new(port), Some(sock.clone()))
.await