mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
test: bind daemon ports without probe races
This commit is contained in:
@@ -27,7 +27,6 @@ use futures_util::{SinkExt, StreamExt};
|
||||
use rand::Rng;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::sync::{Mutex, mpsc};
|
||||
use tokio_tungstenite::tungstenite::handshake::client::generate_key;
|
||||
use tokio_tungstenite::tungstenite::http::Request;
|
||||
@@ -46,9 +45,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-queue");
|
||||
let handle = daemon::run(DaemonConfig::new(port), Some(sock.clone()))
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user