summaryrefslogtreecommitdiff
path: root/crates/utils/tcp_connection/tcp_connection_test
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-09-21 18:44:15 +0800
committer魏曹先生 <1992414357@qq.com>2025-09-21 18:44:15 +0800
commitf9e1a2c71bc2de181d075b16348359c0660ad8b0 (patch)
tree51736076df135ba84ffe5b0eb8b4420a33729035 /crates/utils/tcp_connection/tcp_connection_test
parent42e8188d023fd7ff2c1000e95211e2c4b1ec8868 (diff)
Fixed Challenge
Diffstat (limited to 'crates/utils/tcp_connection/tcp_connection_test')
-rw-r--r--crates/utils/tcp_connection/tcp_connection_test/src/test_challenge.rs18
-rw-r--r--crates/utils/tcp_connection/tcp_connection_test/src/test_connection.rs2
2 files changed, 16 insertions, 4 deletions
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<ExampleChallengeClientHandle> 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<ExampleClientHandle> for ExampleServerHandle {
#[tokio::test]
async fn test_connection_with_example_handle() {
- let host = "localhost";
+ let host = "localhost:5012";
// Server setup
let Ok(server_target) =