From 8e44950e7b35d56ce4e29bbed36a2050720a3613 Mon Sep 17 00:00:00 2001 From: ljy9810 Date: Sat, 29 Mar 2025 14:44:57 +0800 Subject: [PATCH] =?UTF-8?q?commonlibrary=E5=AD=90=E7=B3=BB=E7=BB=9FTDD?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ljy9810 --- ylong_http_client/BUILD.gn | 2 +- ylong_http_client/src/async_impl/dns/doh.rs | 62 --------------------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/ylong_http_client/BUILD.gn b/ylong_http_client/BUILD.gn index e70774a..ffb399e 100644 --- a/ylong_http_client/BUILD.gn +++ b/ylong_http_client/BUILD.gn @@ -44,7 +44,7 @@ ohos_rust_shared_library("ylong_http_client_inner") { } ohos_rust_unittest("rust_ylong_http_client_test_ut") { - module_out_path = "ylong_http/ylong_http_client" + module_out_path = "ylong_http/ylong_http" rustflags = [ "--cfg=feature=\"async\"", diff --git a/ylong_http_client/src/async_impl/dns/doh.rs b/ylong_http_client/src/async_impl/dns/doh.rs index a9136da..e0ae30b 100644 --- a/ylong_http_client/src/async_impl/dns/doh.rs +++ b/ylong_http_client/src/async_impl/dns/doh.rs @@ -370,66 +370,4 @@ mod ut_doh_test { assert_eq!(addrs, vec![]); assert_eq!(ttl, 0); } - - /// UT test case for `DohResolver::resolve` - /// - /// # Brief - /// 1. Creates a doh resolver. - /// 2. Calls resolve to get socket address twice. - /// 3. Verifies the second resolver is faster than the first one. - /// 4. Verifies the second resolver result as same as the first one. - #[tokio::test] - #[cfg(feature = "tokio_base")] - async fn ut_doh_resolver_resolve() { - let authority = "example.com:0"; - let resolver = - DohResolver::new("https://1.12.12.12/dns-query").set_ttl(Duration::from_secs(50)); - let start1 = Instant::now(); - let addrs1 = resolver.resolve(authority).await; - let duration1 = start1.elapsed(); - assert!(addrs1.is_ok()); - tokio::time::sleep(Duration::from_millis(10)).await; - let start2 = Instant::now(); - let addrs2 = resolver.resolve(authority).await; - let duration2 = start2.elapsed(); - assert!(duration1 > duration2); - assert!(addrs2.is_ok()); - if let (Ok(addr1), Ok(addr2)) = (addrs1, addrs2) { - let vec1: Vec = addr1.collect(); - let vec2: Vec = addr2.collect(); - assert_eq!(vec1, vec2); - } - } - - /// UT test case for `DohResolver::resolve` - /// - /// # Brief - /// 1. Creates a doh resolver. - /// 2. Calls resolve to get socket address twice. - /// 3. Verifies the second resolver is faster than the first one. - /// 4. Verifies the second resolver result as same as the first one. - #[test] - #[cfg(feature = "ylong_base")] - fn ut_doh_resolver_resolve() { - ylong_runtime::block_on(async { - let authority = "example.com:0"; - let resolver = - DohResolver::new("https://1.12.12.12/dns-query").set_ttl(Duration::from_secs(50)); - let start1 = Instant::now(); - let addrs1 = resolver.resolve(authority).await; - let duration1 = start1.elapsed(); - assert!(addrs1.is_ok()); - ylong_runtime::time::sleep(Duration::from_millis(10)).await; - let start2 = Instant::now(); - let addrs2 = resolver.resolve(authority).await; - let duration2 = start2.elapsed(); - assert!(duration1 > duration2); - assert!(addrs2.is_ok()); - if let (Ok(addr1), Ok(addr2)) = (addrs1, addrs2) { - let vec1: Vec = addr1.collect(); - let vec2: Vec = addr2.collect(); - assert_eq!(vec1, vec2); - } - }); - } } -- Gitee