From f9e1a2c71bc2de181d075b16348359c0660ad8b0 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 21 Sep 2025 18:44:15 +0800 Subject: Fixed Challenge --- .../tcp_connection_test/src/test_challenge.rs | 18 +++++++++++++++--- .../tcp_connection_test/src/test_connection.rs | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'crates/utils/tcp_connection/tcp_connection_test/src') diff --git a/crates/utils/tcp_connection/tcp_connection_test/src/test_challenge.rs b/crates/utils/tcp_connection/tcp_connection_test/src/test_challenge.rs index 57d3819..723bf52 100644 --- a/crates/utils/tcp_connection/tcp_connection_test/src/test_challenge.rs +++ b/crates/utils/tcp_connection/tcp_connection_test/src/test_challenge.rs @@ -6,7 +6,10 @@ use tcp_connection::{ target::TcpServerTarget, target_configure::ServerTargetConfig, }; -use tokio::{join, time::sleep}; +use tokio::{ + join, + time::{sleep, timeout}, +}; pub(crate) struct ExampleChallengeClientHandle; @@ -38,7 +41,7 @@ impl ServerHandle for ExampleChallengeServerHandle #[tokio::test] async fn test_connection_with_challenge_handle() -> Result<(), std::io::Error> { - let host = "localhost"; + let host = "localhost:5011"; // Server setup let Ok(server_target) = TcpServerTarget::< @@ -76,7 +79,16 @@ async fn test_connection_with_challenge_handle() -> Result<(), std::io::Error> { let _ = client_target.connect().await; }; - let _ = async { join!(future_client, future_server) }.await; + let test_timeout = Duration::from_secs(10); + + timeout(test_timeout, async { join!(future_client, future_server) }) + .await + .map_err(|_| { + std::io::Error::new( + std::io::ErrorKind::TimedOut, + format!("Test timed out after {:?}", test_timeout), + ) + })?; Ok(()) } diff --git a/crates/utils/tcp_connection/tcp_connection_test/src/test_connection.rs b/crates/utils/tcp_connection/tcp_connection_test/src/test_connection.rs index d9fa123..f35fd80 100644 --- a/crates/utils/tcp_connection/tcp_connection_test/src/test_connection.rs +++ b/crates/utils/tcp_connection/tcp_connection_test/src/test_connection.rs @@ -49,7 +49,7 @@ impl ServerHandle for ExampleServerHandle { #[tokio::test] async fn test_connection_with_example_handle() { - let host = "localhost"; + let host = "localhost:5012"; // Server setup let Ok(server_target) = -- cgit