From 2995b36aae49b02046fdb4ddc9923053c3da5842 Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Fri, 3 May 2024 13:45:44 -0700 Subject: [PATCH] move iot verifier tests to single file - remove `#[allow(dead_code)]` --- .../tests/{ => integrations}/common/mod.rs | 14 -------------- iot_verifier/tests/integrations/main.rs | 7 +++++++ .../tests/{ => integrations}/purger_tests.rs | 2 +- .../{ => integrations}/rewarder_operations.rs | 3 +-- .../tests/{ => integrations}/rewarder_oracles.rs | 3 +-- .../tests/{ => integrations}/rewarder_poc_dc.rs | 3 +-- .../tests/{ => integrations}/runner_tests.rs | 3 +-- 7 files changed, 12 insertions(+), 23 deletions(-) rename iot_verifier/tests/{ => integrations}/common/mod.rs (98%) create mode 100644 iot_verifier/tests/integrations/main.rs rename iot_verifier/tests/{ => integrations}/purger_tests.rs (99%) rename iot_verifier/tests/{ => integrations}/rewarder_operations.rs (96%) rename iot_verifier/tests/{ => integrations}/rewarder_oracles.rs (97%) rename iot_verifier/tests/{ => integrations}/rewarder_poc_dc.rs (99%) rename iot_verifier/tests/{ => integrations}/runner_tests.rs (99%) diff --git a/iot_verifier/tests/common/mod.rs b/iot_verifier/tests/integrations/common/mod.rs similarity index 98% rename from iot_verifier/tests/common/mod.rs rename to iot_verifier/tests/integrations/common/mod.rs index c21a6d759..c9f00f01c 100644 --- a/iot_verifier/tests/common/mod.rs +++ b/iot_verifier/tests/integrations/common/mod.rs @@ -44,7 +44,6 @@ pub struct MockFileSinkReceiver { pub receiver: tokio::sync::mpsc::Receiver, } -#[allow(dead_code)] impl MockFileSinkReceiver { pub async fn receive(&mut self) -> Option> { match timeout(seconds(2), self.receiver.recv()).await { @@ -142,7 +141,6 @@ fn seconds(s: u64) -> std::time::Duration { std::time::Duration::from_secs(s) } -#[allow(dead_code)] pub fn create_valid_beacon_report( pubkey: &str, received_timestamp: DateTime, @@ -165,7 +163,6 @@ pub fn create_valid_beacon_report( ) } -#[allow(dead_code)] pub fn create_valid_witness_report( pubkey: &str, received_timestamp: DateTime, @@ -186,7 +183,6 @@ pub fn create_valid_witness_report( ) } -#[allow(dead_code)] pub fn beacon_report_to_ingest_report( report: IotBeaconReport, received_timestamp: DateTime, @@ -197,7 +193,6 @@ pub fn beacon_report_to_ingest_report( } } -#[allow(dead_code)] pub fn witness_report_to_ingest_report( report: IotWitnessReport, received_timestamp: DateTime, @@ -208,7 +203,6 @@ pub fn witness_report_to_ingest_report( } } -#[allow(dead_code)] pub async fn inject_beacon_report( pool: PgPool, beacon: IotBeaconIngestReport, @@ -237,7 +231,6 @@ pub async fn inject_beacon_report( Ok(()) } -#[allow(dead_code)] pub async fn inject_invalid_beacon_report( pool: PgPool, beacon: IotBeaconIngestReport, @@ -266,7 +259,6 @@ pub async fn inject_invalid_beacon_report( Ok(()) } -#[allow(dead_code)] pub async fn inject_witness_report( pool: PgPool, witness: IotWitnessIngestReport, @@ -295,7 +287,6 @@ pub async fn inject_witness_report( Ok(()) } -#[allow(dead_code)] pub async fn inject_entropy_report(pool: PgPool, ts: DateTime) -> anyhow::Result<()> { let data = REMOTE_ENTROPY.to_vec(); let id = hash(&data).as_bytes().to_vec(); @@ -305,7 +296,6 @@ pub async fn inject_entropy_report(pool: PgPool, ts: DateTime) -> anyhow::R Ok(()) } -#[allow(dead_code)] pub async fn inject_last_beacon( txn: &mut Transaction<'_, Postgres>, gateway: PublicKeyBinary, @@ -314,7 +304,6 @@ pub async fn inject_last_beacon( LastBeaconReciprocity::update_last_timestamp(&mut *txn, &gateway, ts).await } -#[allow(dead_code)] pub async fn inject_last_witness( txn: &mut Transaction<'_, Postgres>, gateway: PublicKeyBinary, @@ -323,7 +312,6 @@ pub async fn inject_last_witness( LastWitness::update_last_timestamp(&mut *txn, &gateway, ts).await } -#[allow(dead_code)] pub fn valid_gateway() -> GatewayInfo { GatewayInfo { address: PublicKeyBinary::from_str(BEACONER1).unwrap(), @@ -332,7 +320,6 @@ pub fn valid_gateway() -> GatewayInfo { } } -#[allow(dead_code)] pub fn valid_gateway_stream() -> Vec { vec![ GatewayInfo { @@ -413,7 +400,6 @@ pub fn valid_gateway_stream() -> Vec { ] } -#[allow(dead_code)] pub fn valid_region_params() -> RegionParamsInfo { let region_params = beacon::RegionParams::from_bytes(ProtoRegion::Eu868.into(), 60, EU868_PARAMS, 0) diff --git a/iot_verifier/tests/integrations/main.rs b/iot_verifier/tests/integrations/main.rs new file mode 100644 index 000000000..5be3af42d --- /dev/null +++ b/iot_verifier/tests/integrations/main.rs @@ -0,0 +1,7 @@ +mod common; + +mod purger_tests; +mod rewarder_operations; +mod rewarder_oracles; +mod rewarder_poc_dc; +mod runner_tests; diff --git a/iot_verifier/tests/purger_tests.rs b/iot_verifier/tests/integrations/purger_tests.rs similarity index 99% rename from iot_verifier/tests/purger_tests.rs rename to iot_verifier/tests/integrations/purger_tests.rs index 59d035441..6daafb641 100644 --- a/iot_verifier/tests/purger_tests.rs +++ b/iot_verifier/tests/integrations/purger_tests.rs @@ -1,4 +1,4 @@ -mod common; +use crate::common; use chrono::{Duration as ChronoDuration, TimeZone, Utc}; use helium_crypto::PublicKeyBinary; use helium_proto::services::poc_lora::{ diff --git a/iot_verifier/tests/rewarder_operations.rs b/iot_verifier/tests/integrations/rewarder_operations.rs similarity index 96% rename from iot_verifier/tests/rewarder_operations.rs rename to iot_verifier/tests/integrations/rewarder_operations.rs index 3fc3496f6..509b86676 100644 --- a/iot_verifier/tests/rewarder_operations.rs +++ b/iot_verifier/tests/integrations/rewarder_operations.rs @@ -1,5 +1,4 @@ -mod common; -use crate::common::MockFileSinkReceiver; +use crate::common::{self, MockFileSinkReceiver}; use chrono::{Duration as ChronoDuration, Utc}; use helium_proto::services::poc_lora::OperationalReward; use iot_verifier::{reward_share, rewarder}; diff --git a/iot_verifier/tests/rewarder_oracles.rs b/iot_verifier/tests/integrations/rewarder_oracles.rs similarity index 97% rename from iot_verifier/tests/rewarder_oracles.rs rename to iot_verifier/tests/integrations/rewarder_oracles.rs index 994905791..064765244 100644 --- a/iot_verifier/tests/rewarder_oracles.rs +++ b/iot_verifier/tests/integrations/rewarder_oracles.rs @@ -1,5 +1,4 @@ -mod common; -use crate::common::MockFileSinkReceiver; +use crate::common::{self, MockFileSinkReceiver}; use chrono::{Duration as ChronoDuration, Utc}; use helium_proto::services::poc_lora::UnallocatedReward; use iot_verifier::{reward_share, rewarder}; diff --git a/iot_verifier/tests/rewarder_poc_dc.rs b/iot_verifier/tests/integrations/rewarder_poc_dc.rs similarity index 99% rename from iot_verifier/tests/rewarder_poc_dc.rs rename to iot_verifier/tests/integrations/rewarder_poc_dc.rs index 7aa5d82ac..fefe5acf5 100644 --- a/iot_verifier/tests/rewarder_poc_dc.rs +++ b/iot_verifier/tests/integrations/rewarder_poc_dc.rs @@ -1,5 +1,4 @@ -mod common; -use crate::common::MockFileSinkReceiver; +use crate::common::{self, MockFileSinkReceiver}; use chrono::{DateTime, Duration as ChronoDuration, Utc}; use helium_crypto::PublicKeyBinary; use helium_proto::services::poc_lora::{GatewayReward, UnallocatedReward, UnallocatedRewardType}; diff --git a/iot_verifier/tests/runner_tests.rs b/iot_verifier/tests/integrations/runner_tests.rs similarity index 99% rename from iot_verifier/tests/runner_tests.rs rename to iot_verifier/tests/integrations/runner_tests.rs index cd0fca038..628980600 100644 --- a/iot_verifier/tests/runner_tests.rs +++ b/iot_verifier/tests/integrations/runner_tests.rs @@ -1,7 +1,6 @@ -mod common; +use crate::common::{self, MockFileSinkReceiver}; use async_trait::async_trait; use chrono::{DateTime, Duration as ChronoDuration, TimeZone, Utc}; -use common::MockFileSinkReceiver; use denylist::DenyList; use futures_util::{stream, StreamExt as FuturesStreamExt}; use helium_crypto::PublicKeyBinary;