diff --git a/ylong_http_client/BUILD.gn b/ylong_http_client/BUILD.gn index e70774a42f747f1aa07cfb691b23fc14ea72a6e6..ffb399e2902f038182301b5fc85da59b93824531 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 a9136da58d459e9e4c17af1a711439c5481ddb47..e0ae30b5691011f6cefdbba65a7d205ef47ef7f4 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); - } - }); - } }