fix clippy

This commit is contained in:
benedettadavico
2025-04-08 17:15:47 +02:00
parent 1a5c54084e
commit caa94c142f
10 changed files with 64 additions and 25 deletions
+3
View File
@@ -1,3 +1,6 @@
#[path = "public-api/utils.rs"]
mod utils;
#[path = "public-api/api_status.rs"]
mod api_status;
+1 -1
View File
@@ -1,5 +1,5 @@
mod utils;
use utils::{base_url, test_client, validate_json_response};
use crate::utils::{base_url, test_client, validate_json_response};
#[tokio::test]
async fn test_health() {
@@ -1,5 +1,5 @@
mod utils;
use utils::{base_url, test_client, validate_json_response};
use crate::utils::{base_url, test_client, validate_json_response};
#[tokio::test]
async fn test_get_circulating_supply() {
+1 -1
View File
@@ -1,5 +1,5 @@
mod utils;
use utils::{base_url, test_client, validate_json_response};
use crate::utils::{base_url, test_client, validate_json_response};
#[tokio::test]
async fn test_get_current_epoch() {
+1 -1
View File
@@ -1,5 +1,5 @@
mod utils;
use utils::{base_url, test_client, validate_json_response};
use crate::utils::{base_url, test_client, validate_json_response};
#[tokio::test]
async fn test_get_chain_status() {
+5 -5
View File
@@ -1,6 +1,6 @@
mod utils;
use crate::utils::{base_url, get_any_node_id, test_client, validate_json_response};
use chrono::Utc;
use utils::{base_url, get_any_node_id, test_client, validate_json_response};
#[tokio::test]
async fn test_get_bonded_nodes() {
@@ -15,7 +15,7 @@ async fn test_get_bonded_nodes() {
assert!(data.is_array(), "Expected 'data' to be an array");
assert!(
data.as_array().unwrap().len() > 0,
!data.as_array().unwrap().is_empty(),
"Expected at least one bonded node"
);
}
@@ -33,7 +33,7 @@ async fn test_get_described_nodes() {
assert!(data.is_array(), "Expected 'data' to be an array");
assert!(
data.as_array().unwrap().len() > 0,
!data.as_array().unwrap().is_empty(),
"Expected at least one node to appear"
);
}
@@ -126,7 +126,7 @@ async fn test_get_performance_history() {
assert!(data.is_array(), "Expected 'history.data' to be an array");
assert!(
data.as_array().unwrap().len() > 0,
!data.as_array().unwrap().is_empty(),
"Expected at least one performance history entry"
);
}
@@ -168,7 +168,7 @@ async fn test_get_uptime_history() {
assert!(data.is_array(), "Expected 'history.data' to be an array");
assert!(
data.as_array().unwrap().len() > 0,
!data.as_array().unwrap().is_empty(),
"Expected at least one performance history entry"
);
}
+5 -2
View File
@@ -1,6 +1,6 @@
mod utils;
use crate::utils::{base_url, test_client};
use serde_json::Value;
use utils::{base_url, test_client};
#[tokio::test]
async fn test_get_config_score_details() {
@@ -16,7 +16,10 @@ async fn test_get_config_score_details() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let version_history = json
.get("version_history")
+30 -9
View File
@@ -1,6 +1,6 @@
mod utils;
use crate::utils::{base_url, test_client};
use serde_json::Value;
use utils::{base_url, test_client};
#[tokio::test]
async fn test_get_skimmed_nodes_active() {
@@ -16,7 +16,10 @@ async fn test_get_skimmed_nodes_active() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let data = json
.get("nodes")
.and_then(|r| r.get("data"))
@@ -24,7 +27,7 @@ async fn test_get_skimmed_nodes_active() {
assert!(data.is_array(), "Expected 'data' to be an array");
assert!(
data.as_array().unwrap().len() > 0,
!data.as_array().unwrap().is_empty(),
"Expected at least one node to appear"
);
}
@@ -46,7 +49,10 @@ async fn test_get_skimmed_active_mixnodes() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
@@ -77,7 +83,10 @@ async fn test_get_skimmed_all_mixnodes() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
@@ -111,7 +120,10 @@ async fn test_get_skimmed_active_exit_gateways() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
@@ -145,7 +157,10 @@ async fn test_get_skimmed_all_exit_gateways() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
@@ -179,7 +194,10 @@ async fn test_get_skimmed_active_entry_gateways() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
@@ -213,7 +231,10 @@ async fn test_get_skimmed_all_entry_gateways() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let current_epoch_id = json
.get("status")
.and_then(|r| r.get("fresh"))
+5 -2
View File
@@ -1,6 +1,6 @@
mod utils;
use crate::utils::{base_url, get_gateway_identity_key, get_mixnode_node_id, test_client};
use serde_json::Value;
use utils::{base_url, get_gateway_identity_key, get_mixnode_node_id, test_client};
#[tokio::test]
async fn test_get_gateway_unstable_test_results() {
@@ -109,7 +109,10 @@ async fn test_get_latest_network_monitor_run_details() {
res.status()
);
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
let monitor_run_id = json
.get("monitor_run_id")
.and_then(|v| v.as_number())
+12 -3
View File
@@ -40,7 +40,10 @@ pub async fn get_any_node_id() -> String {
.send()
.await
.unwrap_or_else(|err| panic!("Failed to send request to {}: {}", url, err));
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
json.get("data")
.and_then(|list| list.as_array())
@@ -61,7 +64,10 @@ pub async fn get_mixnode_node_id() -> u64 {
.send()
.await
.unwrap_or_else(|err| panic!("Failed to send request to {}: {}", url, err));
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
json.get("data")
.and_then(|v| v.as_array())
@@ -88,7 +94,10 @@ pub async fn get_gateway_identity_key() -> String {
.send()
.await
.unwrap_or_else(|err| panic!("Failed to send request to {}: {}", url, err));
let json: Value = res.json().await.unwrap();
let json: Value = res
.json()
.await
.unwrap_or_else(|err| panic!("Failed to parse response as JSON: {}", err));
json.get("data")
.and_then(|v| v.as_array())