Assorted CI fixes

This commit is contained in:
durch
2025-09-01 14:48:19 +02:00
parent edb797da68
commit c79471e9ad
21 changed files with 91 additions and 98 deletions
+3 -3
View File
@@ -100,14 +100,14 @@ mod tests {
// Some(vec!["https://cdn77.com"]),
// ).unwrap(); // cdn77
let client = ClientBuilder::new::<_, &str>(url1)
let client = ClientBuilder::new(url1)
.expect("bad url")
.with_fronting(FrontPolicy::Always)
.build::<&str>()
.build()
.expect("failed to build client");
let response = client
.send_request::<_, (), &str, &str, &str>(
.send_request::<_, (), &str, &str>(
reqwest::Method::GET,
&["api", "v1", "network", "details"],
NO_PARAMS,
+5 -8
View File
@@ -95,10 +95,10 @@ async fn api_client_retry() -> Result<(), Box<dyn std::error::Error>> {
"http://example.com/".parse()?,
])
.with_retries(3)
.build::<HttpClientError>()?;
.build()?;
let req = client.create_get_request(&["/"], NO_PARAMS).unwrap();
let resp = client.send::<HttpClientError>(req).await?;
let resp = client.send(req).await?;
assert_eq!(resp.status(), 200);
@@ -111,10 +111,7 @@ async fn api_client_retry() -> Result<(), Box<dyn std::error::Error>> {
#[test]
fn host_updating() {
let url = Url::new("http://example.com", None).unwrap();
let mut client = ClientBuilder::new::<_, &str>(url)
.unwrap()
.build::<&str>()
.unwrap();
let mut client = ClientBuilder::new(url).unwrap().build().unwrap();
// check that the url is set correctly
let current_url = client.current_url();
@@ -171,10 +168,10 @@ fn host_updating() {
#[cfg(feature = "tunneling")]
fn fronted_host_updating() {
let url = Url::new("http://example.com", Some(vec!["http://front1.com"])).unwrap();
let mut client = ClientBuilder::new::<_, &str>(url)
let mut client = ClientBuilder::new(url)
.unwrap()
.with_fronting(crate::fronted::FrontPolicy::Always)
.build::<&str>()
.build()
.unwrap();
// check that the url is set correctly
+10 -13
View File
@@ -72,19 +72,16 @@ pub async fn current_network_topology_async(
}
};
let api_client = nym_http_api_client::Client::builder::<
_,
nym_validator_client::models::RequestError,
>(url.clone())
.map_err(|_err| WasmCoreError::MalformedUrl {
raw: nym_api_url.to_string(),
source: url::ParseError::EmptyHost,
})?
.build::<nym_validator_client::models::RequestError>()
.map_err(|_err| WasmCoreError::MalformedUrl {
raw: nym_api_url.to_string(),
source: url::ParseError::EmptyHost,
})?;
let api_client = nym_http_api_client::Client::builder(url.clone())
.map_err(|_err| WasmCoreError::MalformedUrl {
raw: nym_api_url.to_string(),
source: url::ParseError::EmptyHost,
})?
.build()
.map_err(|_err| WasmCoreError::MalformedUrl {
raw: nym_api_url.to_string(),
source: url::ParseError::EmptyHost,
})?;
let rewarded_set = api_client.get_current_rewarded_set().await?;
let mixnodes_res = api_client
.get_all_basic_active_mixing_assigned_nodes_with_metadata()
@@ -7,16 +7,14 @@ use tracing::instrument;
use nym_http_api_client::{ApiClient, Client, HttpClientError, NO_PARAMS};
use nym_wireguard_private_metadata_shared::{
routes, Version, {ErrorResponse, Request, Response},
routes, Version, {Request, Response},
};
pub type WireguardMetadataApiClientError = HttpClientError<ErrorResponse>;
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait WireguardMetadataApiClient: ApiClient {
#[instrument(level = "debug", skip(self))]
async fn version(&self) -> Result<Version, WireguardMetadataApiClientError> {
async fn version(&self) -> Result<Version, HttpClientError> {
let version: u64 = self
.get_json(
&[routes::V1_API_VERSION, routes::BANDWIDTH, routes::VERSION],
@@ -30,7 +28,7 @@ pub trait WireguardMetadataApiClient: ApiClient {
async fn available_bandwidth(
&self,
request_body: &Request,
) -> Result<Response, WireguardMetadataApiClientError> {
) -> Result<Response, HttpClientError> {
self.post_json(
&[routes::V1_API_VERSION, routes::BANDWIDTH, routes::AVAILABLE],
NO_PARAMS,
@@ -40,10 +38,7 @@ pub trait WireguardMetadataApiClient: ApiClient {
}
#[instrument(level = "debug", skip(self, request_body))]
async fn topup_bandwidth(
&self,
request_body: &Request,
) -> Result<Response, WireguardMetadataApiClientError> {
async fn topup_bandwidth(&self, request_body: &Request) -> Result<Response, HttpClientError> {
self.post_json(
&[routes::V1_API_VERSION, routes::BANDWIDTH, routes::TOPUP],
NO_PARAMS,
@@ -13,7 +13,7 @@ mod tests {
use nym_wireguard_private_metadata_server::{
AppState, PeerControllerTransceiver, RouterBuilder,
};
use nym_wireguard_private_metadata_shared::{latest, v0, v1, ErrorResponse};
use nym_wireguard_private_metadata_shared::{latest, v0, v1};
use tokio::{net::TcpListener, sync::mpsc};
pub(crate) const VERIFIER_AVAILABLE_BANDWIDTH: i64 = 42;
@@ -140,7 +140,7 @@ mod tests {
.await
.unwrap();
});
Client::new_url::<_, ErrorResponse>(addr.to_string(), None).unwrap()
Client::new_url(addr.to_string(), None).unwrap()
}
#[tokio::test]
@@ -15,7 +15,6 @@ pub(crate) mod test {
use nym_http_api_common::{FormattedResponse, OutputParams};
use nym_wireguard::{peer_controller::PeerControlRequest, CONTROL_CHANNEL_SIZE};
use nym_wireguard_private_metadata_server::PeerControllerTransceiver;
use nym_wireguard_private_metadata_shared::ErrorResponse;
use nym_wireguard_private_metadata_shared::{
v0 as latest, AxumErrorResponse, AxumResult, Construct, Extract, Request, Response,
};
@@ -141,6 +140,6 @@ pub(crate) mod test {
.await
.unwrap();
});
Client::new_url::<_, ErrorResponse>(addr.to_string(), None).unwrap()
Client::new_url(addr.to_string(), None).unwrap()
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ impl TestSetup {
}
}
pub fn query_ctx(&self) -> QueryCtx {
pub fn query_ctx(&self) -> QueryCtx<'_> {
QueryCtx::from((self.deps.as_ref(), self.env.clone()))
}
}
+2 -2
View File
@@ -73,13 +73,13 @@ impl TestSetupSimple {
message_info(&admin, &[])
}
pub fn execute_ctx(&mut self, sender: MessageInfo) -> ExecCtx {
pub fn execute_ctx(&mut self, sender: MessageInfo) -> ExecCtx<'_> {
let env = self.env.clone();
ExecCtx::from((self.deps.as_mut(), env, sender))
}
#[allow(dead_code)]
pub fn query_ctx(&self) -> QueryCtx {
pub fn query_ctx(&self) -> QueryCtx<'_> {
QueryCtx::from((self.deps.as_ref(), self.env.clone()))
}
@@ -300,7 +300,7 @@ mod tests {
let amount1 = coin(100_000_000, TEST_COIN_DENOM);
let sender1 = message_info(owner, &[amount1.clone()]);
let sender1 = message_info(owner, std::slice::from_ref(&amount1));
try_delegate_to_node(test.deps_mut(), env.clone(), sender1, mix_id).unwrap();
+3 -3
View File
@@ -131,7 +131,7 @@ impl PreInitContract {
}
}
pub(crate) fn deps(&self) -> Deps {
pub(crate) fn deps(&self) -> Deps<'_> {
Deps {
storage: &self.storage,
api: &self.api,
@@ -139,7 +139,7 @@ impl PreInitContract {
}
}
pub(crate) fn deps_mut(&mut self) -> DepsMut {
pub(crate) fn deps_mut(&mut self) -> DepsMut<'_> {
DepsMut {
storage: &mut self.storage,
api: &self.api,
@@ -147,7 +147,7 @@ impl PreInitContract {
}
}
pub(crate) fn querier(&self) -> QuerierWrapper {
pub(crate) fn querier(&self) -> QuerierWrapper<'_> {
self.tester_builder.querier()
}
+1 -1
View File
@@ -137,7 +137,7 @@ mod tests {
let response = execute(
deps.as_mut(),
env.clone(),
message_info(&admin, &[amount.clone()]),
message_info(&admin, std::slice::from_ref(&amount)),
msg,
);
assert_eq!(
+3 -6
View File
@@ -163,12 +163,9 @@ async fn nym_topology_from_env() -> anyhow::Result<NymTopology> {
let api_url = std::env::var(NYM_API)?;
info!("Generating topology from {api_url}");
let client = nym_http_api_client::Client::builder::<
_,
nym_validator_client::models::RequestError,
>(api_url)?
.with_user_agent(UserAgent::from(bin_info!()))
.build::<nym_validator_client::models::RequestError>()?;
let client = nym_http_api_client::Client::builder(api_url)?
.with_user_agent(UserAgent::from(bin_info!()))
.build()?;
let rewarded_set = client.get_current_rewarded_set().await?;
+30
View File
@@ -4213,6 +4213,8 @@ dependencies = [
"reqwest 0.12.15",
"serde",
"serde_json",
"serde_plain",
"serde_yaml",
"thiserror 2.0.12",
"tracing",
"url",
@@ -6297,6 +6299,15 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_plain"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50"
dependencies = [
"serde",
]
[[package]]
name = "serde_repr"
version = "0.1.20"
@@ -6359,6 +6370,19 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.8.0",
"itoa 1.0.15",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
name = "serdect"
version = "0.2.0"
@@ -7836,6 +7860,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "untrusted"
version = "0.9.0"
-6
View File
@@ -2,7 +2,6 @@ use nym_contracts_common::signing::SigningAlgorithm;
use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError;
use nym_node_requests::api::client::NymNodeApiClientError;
use nym_types::error::TypesError;
use nym_validator_client::nym_api::error::NymAPIError;
use nym_validator_client::signing::direct_wallet::DirectSecp256k1HdWalletError;
use nym_validator_client::{nyxd::error::NyxdError, ValidatorClientError};
use nym_wallet_types::network::Network;
@@ -45,11 +44,6 @@ pub enum BackendError {
source: eyre::Report,
},
#[error(transparent)]
NymApiError {
#[from]
source: NymAPIError,
},
#[error(transparent)]
NymNodeApiError {
#[from]
source: NymNodeApiClientError,
@@ -15,7 +15,6 @@ use nym_mixnet_contract_common::nym_node::{NodeConfigUpdate, StakeSaturationResp
use nym_mixnet_contract_common::{MixNodeConfigUpdate, NodeId, NymNode};
use nym_node_requests::api::client::NymNodeApiClientExt;
use nym_node_requests::api::v1::node::models::NodeDescription;
use nym_node_requests::api::ErrorResponse;
use nym_types::currency::DecCoin;
use nym_types::gateway::GatewayBond;
use nym_types::mixnode::{MixNodeDetails, NodeCostParams};
@@ -586,12 +585,12 @@ pub async fn get_nym_node_description(
port: u16,
) -> Result<NodeDescription, BackendError> {
Ok(
nym_node_requests::api::Client::builder::<_, ErrorResponse>(format!(
nym_node_requests::api::Client::builder(format!(
"http://{host}:{port}"
))?
.with_timeout(Duration::from_millis(1000))
.with_user_agent(format!("nym-wallet/{}", env!("CARGO_PKG_VERSION")))
.build::<ErrorResponse>()?
.build()?
.get_description()
.await?,
)
@@ -14,13 +14,10 @@ struct MyTopologyProvider {
impl MyTopologyProvider {
fn new(nym_api_url: Url) -> MyTopologyProvider {
let validator_client = nym_http_api_client::Client::builder::<
_,
nym_validator_client::models::RequestError,
>(nym_api_url)
.expect("Failed to create API client builder")
.build::<nym_validator_client::models::RequestError>()
.expect("Failed to build API client");
let validator_client = nym_http_api_client::Client::builder(nym_api_url)
.expect("Failed to create API client builder")
.build()
.expect("Failed to build API client");
MyTopologyProvider { validator_client }
}
@@ -91,13 +91,10 @@ impl NetworkManager {
"⌛waiting for any gateway to appear in the directory ({api_url})..."
));
let api_client = nym_http_api_client::Client::builder::<
_,
nym_validator_client::models::RequestError,
>(api_url.clone())
.expect("Failed to create API client builder")
.build::<nym_validator_client::models::RequestError>()
.expect("Failed to build API client");
let api_client = nym_http_api_client::Client::builder(api_url.clone())
.expect("Failed to create API client builder")
.build()
.expect("Failed to build API client");
let wait_fut = async {
let inner_fut = async {
@@ -56,12 +56,10 @@ impl SignerStatus {
}
};
nym_http_api_client::Client::builder::<_, nym_validator_client::models::RequestError>(
api_endpoint,
)
.ok()?
.build::<nym_validator_client::models::RequestError>()
.ok()
nym_http_api_client::Client::builder(api_endpoint)
.ok()?
.build()
.ok()
}
pub(crate) async fn try_update_api_version(&mut self) {
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::vpn_api_client::NymVpnApiClientError;
use nym_http_api_client::HttpClientError;
use thiserror::Error;
use wasm_utils::wasm_error;
@@ -16,7 +16,7 @@ pub enum ZkNymError {
#[error("failed to contact the vpn api")]
HttpClientFailure {
#[from]
source: NymVpnApiClientError,
source: HttpClientError,
},
#[error("the provided shares and issuers are not from the same epoch! {shares} and {issuers}")]
InconsistentEpochId { shares: u64, issuers: u64 },
+9 -11
View File
@@ -1,14 +1,14 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use super::NymVpnApiClientError;
use crate::error::ZkNymError;
use crate::vpn_api_client::types::{
AttributesResponse, MasterVerificationKeyResponse, PartialVerificationKeysResponse,
};
use async_trait::async_trait;
pub use nym_http_api_client::Client;
use nym_http_api_client::{parse_response, ApiClient, IntoUrl, PathSegments, NO_PARAMS};
use nym_http_api_client::{
parse_response, ApiClient, HttpClientError, IntoUrl, PathSegments, NO_PARAMS,
};
use serde::de::DeserializeOwned;
#[allow(dead_code)]
@@ -34,13 +34,11 @@ pub fn new_client(
#[allow(dead_code)]
#[async_trait(?Send)]
pub trait NymVpnApiClient {
async fn simple_get<T>(&self, path: PathSegments<'_>) -> Result<T, NymVpnApiClientError>
async fn simple_get<T>(&self, path: PathSegments<'_>) -> Result<T, HttpClientError>
where
T: DeserializeOwned;
async fn get_prehashed_public_attributes(
&self,
) -> Result<AttributesResponse, NymVpnApiClientError> {
async fn get_prehashed_public_attributes(&self) -> Result<AttributesResponse, HttpClientError> {
self.simple_get(&[
"/api",
"/v1",
@@ -52,7 +50,7 @@ pub trait NymVpnApiClient {
async fn get_partial_verification_keys(
&self,
) -> Result<PartialVerificationKeysResponse, NymVpnApiClientError> {
) -> Result<PartialVerificationKeysResponse, HttpClientError> {
self.simple_get(&[
"/api",
"/v1",
@@ -64,7 +62,7 @@ pub trait NymVpnApiClient {
async fn get_master_verification_key(
&self,
) -> Result<MasterVerificationKeyResponse, NymVpnApiClientError> {
) -> Result<MasterVerificationKeyResponse, HttpClientError> {
self.simple_get(&[
"/api",
"/v1",
@@ -77,13 +75,13 @@ pub trait NymVpnApiClient {
#[async_trait(?Send)]
impl NymVpnApiClient for VpnApiClient {
async fn simple_get<T>(&self, path: PathSegments<'_>) -> Result<T, NymVpnApiClientError>
async fn simple_get<T>(&self, path: PathSegments<'_>) -> Result<T, HttpClientError>
where
T: DeserializeOwned,
{
let req = self
.inner
.create_get_request(path, NO_PARAMS)
.create_get_request(path, NO_PARAMS)?
.bearer_auth(&self.bearer_token)
.send();
-5
View File
@@ -1,12 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::vpn_api_client::types::ErrorResponse;
use nym_http_api_client::HttpClientError;
#[cfg(test)]
pub(crate) mod client;
pub mod types;
pub type NymVpnApiClientError = HttpClientError<ErrorResponse>;