From f6fe9c3e10d7eb182a52b8d6c6aebef4ee8c7910 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 28 Mar 2025 10:07:10 +0100 Subject: [PATCH] Improve tests (#548) --- ntex/tests/http_openssl.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ntex/tests/http_openssl.rs b/ntex/tests/http_openssl.rs index e46765af..2d2c98f9 100644 --- a/ntex/tests/http_openssl.rs +++ b/ntex/tests/http_openssl.rs @@ -446,13 +446,12 @@ async fn test_h2_client_drop() -> io::Result<()> { let count = count2.clone(); HttpService::build() .h2(move |req: Request| { - let tx = tx.clone(); - let count = count.clone(); + let st = SetOnDrop(count.clone(), tx.clone()); async move { - let _st = SetOnDrop(count, tx); assert!(req.peer_addr().is_some()); assert_eq!(req.version(), Version::HTTP_2); - sleep(Seconds(100)).await; + sleep(Seconds(30)).await; + drop(st); Ok::<_, io::Error>(Response::Ok().finish()) } }) @@ -460,9 +459,9 @@ async fn test_h2_client_drop() -> io::Result<()> { .map_err(|_| ()) }); - let result = timeout(Millis(250), srv.srequest(Method::GET, "/").send()).await; + let result = timeout(Millis(150), srv.srequest(Method::GET, "/").send()).await; assert!(result.is_err()); - let _ = rx.await; + let _ = timeout(Millis(1500), rx).await; assert_eq!(count.load(Ordering::Relaxed), 1); Ok(()) }