diff --git a/nym-api/tests/public-api/api_status.rs b/nym-api/tests/public-api/api_status.rs index a7607832f8..15a90636e8 100644 --- a/nym-api/tests/public-api/api_status.rs +++ b/nym-api/tests/public-api/api_status.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client, validate_json_response}; #[tokio::test] diff --git a/nym-api/tests/public-api/circulating_supply.rs b/nym-api/tests/public-api/circulating_supply.rs index 4190c2556a..171cdfb07e 100644 --- a/nym-api/tests/public-api/circulating_supply.rs +++ b/nym-api/tests/public-api/circulating_supply.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client, validate_json_response}; #[tokio::test] diff --git a/nym-api/tests/public-api/contract_cache.rs b/nym-api/tests/public-api/contract_cache.rs index b67d598c81..cad56cdd51 100644 --- a/nym-api/tests/public-api/contract_cache.rs +++ b/nym-api/tests/public-api/contract_cache.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client, validate_json_response}; #[tokio::test] diff --git a/nym-api/tests/public-api/network.rs b/nym-api/tests/public-api/network.rs index 4503a96f64..4c45a2ed02 100644 --- a/nym-api/tests/public-api/network.rs +++ b/nym-api/tests/public-api/network.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client, validate_json_response}; #[tokio::test] diff --git a/nym-api/tests/public-api/nym_nodes.rs b/nym-api/tests/public-api/nym_nodes.rs index 740adf9367..4686e59116 100644 --- a/nym-api/tests/public-api/nym_nodes.rs +++ b/nym-api/tests/public-api/nym_nodes.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, get_any_node_id, test_client, validate_json_response}; use chrono::Utc; diff --git a/nym-api/tests/public-api/status.rs b/nym-api/tests/public-api/status.rs index 09f826f1a5..c1ac4d6e7d 100644 --- a/nym-api/tests/public-api/status.rs +++ b/nym-api/tests/public-api/status.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client}; use serde_json::Value; diff --git a/nym-api/tests/public-api/unstable_nym_nodes.rs b/nym-api/tests/public-api/unstable_nym_nodes.rs index b3d6705672..c73a18a0c2 100644 --- a/nym-api/tests/public-api/unstable_nym_nodes.rs +++ b/nym-api/tests/public-api/unstable_nym_nodes.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, test_client}; use serde_json::Value; diff --git a/nym-api/tests/public-api/unstable_status.rs b/nym-api/tests/public-api/unstable_status.rs index c8a94d7d0c..361c87e998 100644 --- a/nym-api/tests/public-api/unstable_status.rs +++ b/nym-api/tests/public-api/unstable_status.rs @@ -1,4 +1,3 @@ -mod utils; use crate::utils::{base_url, get_gateway_identity_key, get_mixnode_node_id, test_client}; use serde_json::Value; diff --git a/nym-api/tests/public-api/utils.rs b/nym-api/tests/public-api/utils.rs index 62e51b868f..bf7b162f05 100644 --- a/nym-api/tests/public-api/utils.rs +++ b/nym-api/tests/public-api/utils.rs @@ -7,6 +7,7 @@ pub fn test_client() -> Client { Client::new() } +#[allow(clippy::panic)] pub fn base_url() -> String { dotenv().ok(); @@ -19,6 +20,7 @@ pub fn base_url() -> String { } #[allow(dead_code)] +#[allow(clippy::panic)] pub async fn validate_json_response(res: Response) -> Value { assert!( res.status().is_success(), @@ -33,6 +35,7 @@ pub async fn validate_json_response(res: Response) -> Value { } #[allow(dead_code)] +#[allow(clippy::panic)] pub async fn get_any_node_id() -> String { let url = format!("{}/v1/nym-nodes/bonded", base_url()); let res = test_client() @@ -51,12 +54,12 @@ pub async fn get_any_node_id() -> String { .and_then(|node| node.get("bond_information")) .and_then(|n| n.get("node_id")) .and_then(|v| v.as_u64()) - .map(|id| id.to_string()) - .unwrap_or_else(|| "INVALID_ID".into()) + .unwrap_or(0) .to_string() } #[allow(dead_code)] +#[allow(clippy::panic)] pub async fn get_mixnode_node_id() -> u64 { let url = format!("{}/v1/nym-nodes/described", base_url()); let res = test_client() @@ -71,7 +74,7 @@ pub async fn get_mixnode_node_id() -> u64 { json.get("data") .and_then(|v| v.as_array()) - .expect("Expected 'data' to be an array") + .unwrap_or_else(|| panic!("Expected 'data' to be an array")) .iter() .find(|entry| { entry @@ -79,7 +82,6 @@ pub async fn get_mixnode_node_id() -> u64 { .and_then(|d| d.get("declared_role")) .and_then(|r| r.get("mixnode")) .and_then(|m| m.as_bool()) - .map(|is_mixnode| is_mixnode) .unwrap_or(true) }) .and_then(|node| node.get("node_id").and_then(|v| v.as_u64())) @@ -87,6 +89,7 @@ pub async fn get_mixnode_node_id() -> u64 { } #[allow(dead_code)] +#[allow(clippy::panic)] pub async fn get_gateway_identity_key() -> String { let url = format!("{}/v1/nym-nodes/described", base_url()); let res = test_client() @@ -101,7 +104,7 @@ pub async fn get_gateway_identity_key() -> String { json.get("data") .and_then(|v| v.as_array()) - .expect("Expected 'data' to be an array") + .unwrap_or_else(|| panic!("Expected 'data' to be an array")) .iter() .find(|entry| { entry