From e2e2674306672f64e198cf5b3c8591c0b0f655df Mon Sep 17 00:00:00 2001 From: Nikolay Komarevskiy Date: Thu, 30 May 2024 21:45:33 +0200 Subject: [PATCH] add cfg feature --- ic-agent/src/agent/agent_test.rs | 5 ++++- ic-agent/src/agent/http_transport/hyper_transport.rs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ic-agent/src/agent/agent_test.rs b/ic-agent/src/agent/agent_test.rs index 26313a7ba..bf8c5dd02 100644 --- a/ic-agent/src/agent/agent_test.rs +++ b/ic-agent/src/agent/agent_test.rs @@ -14,8 +14,8 @@ use futures_util::FutureExt; use ic_certification::{Delegation, Label}; use ic_transport_types::{NodeSignature, QueryResponse, RejectCode, RejectResponse, ReplyResponse}; use reqwest::Client; +use std::sync::Arc; use std::{collections::BTreeMap, time::Duration}; -use std::{collections::VecDeque, sync::Arc}; #[cfg(all(target_family = "wasm", feature = "wasm-bindgen"))] use wasm_bindgen_test::wasm_bindgen_test; @@ -50,6 +50,7 @@ fn make_agent_with_route_provider( .unwrap() } +#[cfg(feature = "hyper")] fn make_agent_with_hyper_transport_route_provider( route_provider: Arc, tcp_retries: usize, @@ -61,6 +62,7 @@ fn make_agent_with_hyper_transport_route_provider( client::legacy::{connect::HttpConnector, Client as LegacyClient}, rt::TokioExecutor, }; + use std::collections::VecDeque; let connector = HttpsConnectorBuilder::new() .with_webpki_roots() @@ -382,6 +384,7 @@ async fn reqwest_client_status_okay_when_request_retried() -> Result<(), AgentEr } #[cfg_attr(not(target_family = "wasm"), tokio::test)] +#[cfg(feature = "hyper")] async fn hyper_client_status_okay_when_request_retried() -> Result<(), AgentError> { let map = BTreeMap::new(); let response = serde_cbor::Value::Map(map); diff --git a/ic-agent/src/agent/http_transport/hyper_transport.rs b/ic-agent/src/agent/http_transport/hyper_transport.rs index 672e125ef..622d57c5c 100644 --- a/ic-agent/src/agent/http_transport/hyper_transport.rs +++ b/ic-agent/src/agent/http_transport/hyper_transport.rs @@ -174,7 +174,7 @@ where } let create_request_with_generated_url = || -> Result, AgentError> { - let url = self.route_provider.route()?.join(&endpoint)?; + let url = self.route_provider.route()?.join(endpoint)?; println!("{url}"); let http_request = Request::builder() .method(&method) @@ -305,8 +305,8 @@ where fn status(&self) -> AgentFuture> { Box::pin(async move { - let endpoint = &format!("status"); - self.request(Method::GET, endpoint, None).await + let endpoint = "status".to_string(); + self.request(Method::GET, &endpoint, None).await }) } }