From f95aef90588c83ae73ae582718c35e128d048da4 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Mon, 6 May 2024 15:25:48 -0400 Subject: [PATCH] Clippy and tests --- mobile_verifier/src/coverage.rs | 2 +- .../tests/integrations/boosting_oracles.rs | 1 - .../tests/integrations/common/mod.rs | 36 ++++++++++--------- .../tests/integrations/hex_boosting.rs | 8 +++-- .../tests/integrations/modeled_coverage.rs | 9 +++-- .../tests/integrations/rewarder_poc_dc.rs | 9 +++-- 6 files changed, 38 insertions(+), 27 deletions(-) diff --git a/mobile_verifier/src/coverage.rs b/mobile_verifier/src/coverage.rs index bc486794f..0b2c51c95 100644 --- a/mobile_verifier/src/coverage.rs +++ b/mobile_verifier/src/coverage.rs @@ -177,7 +177,7 @@ impl CoverageDaemon { self.coverage_obj_sink.commit().await?; transaction.commit().await?; - // Tell the data set manager to update the assignments. + // Tell the data set manager to update the assignments. self.new_coverage_object_signal.try_send(())?; Ok(()) diff --git a/mobile_verifier/tests/integrations/boosting_oracles.rs b/mobile_verifier/tests/integrations/boosting_oracles.rs index e61d8e660..bc0126fa6 100644 --- a/mobile_verifier/tests/integrations/boosting_oracles.rs +++ b/mobile_verifier/tests/integrations/boosting_oracles.rs @@ -1,4 +1,3 @@ -use crate::common; use anyhow::Context; use chrono::{DateTime, Duration, Utc}; use file_store::{ diff --git a/mobile_verifier/tests/integrations/common/mod.rs b/mobile_verifier/tests/integrations/common/mod.rs index 9c5b6193d..f165495ff 100644 --- a/mobile_verifier/tests/integrations/common/mod.rs +++ b/mobile_verifier/tests/integrations/common/mod.rs @@ -12,7 +12,7 @@ use mobile_config::{ boosted_hex_info::{BoostedHexInfo, BoostedHexInfoStream}, client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, }; -use mobile_verifier::boosting_oracles::{Assignment, BoostedHexAssignments, HexAssignments}; +use mobile_verifier::boosting_oracles::{Assignment, HexBoostData}; use std::collections::HashMap; use tokio::{sync::mpsc::error::TryRecvError, time::timeout}; @@ -182,24 +182,26 @@ pub fn seconds(s: u64) -> std::time::Duration { type MockAssignmentMap = HashMap; -#[derive(Default)] +pub fn mock_hex_boost_data_default( +) -> HexBoostData { + HexBoostData::builder() + .urbanization(MockAssignmentMap::default()) + .footfall(MockAssignmentMap::default()) + .landtype(MockAssignmentMap::default()) + .build() + .unwrap() +} + #[allow(dead_code)] -pub struct MockHexAssignments { +pub fn mock_hex_boost_data( footfall: MockAssignmentMap, urbanized: MockAssignmentMap, landtype: MockAssignmentMap, -} - -impl MockHexAssignments { - pub fn new( - footfall: MockAssignmentMap, - urbanized: MockAssignmentMap, - landtype: MockAssignmentMap, - ) -> Self { - Self { - footfall, - urbanized, - landtype, - } - } +) -> HexBoostData { + HexBoostData::builder() + .footfall(footfall) + .urbanization(urbanized) + .landtype(landtype) + .build() + .unwrap() } diff --git a/mobile_verifier/tests/integrations/hex_boosting.rs b/mobile_verifier/tests/integrations/hex_boosting.rs index b031e32ec..8dcbb823d 100644 --- a/mobile_verifier/tests/integrations/hex_boosting.rs +++ b/mobile_verifier/tests/integrations/hex_boosting.rs @@ -36,8 +36,12 @@ const BOOST_CONFIG_PUBKEY: &str = "BZM1QTud72B2cpTW7PhEnFmRX7ZWzvY7DpPpNJJuDrWG" async fn update_assignments(pool: &PgPool) -> anyhow::Result<()> { let unassigned_hexes = UnassignedHex::fetch_unassigned(pool); - let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool) - .await?; + let _ = set_oracle_boosting_assignments( + unassigned_hexes, + &common::mock_hex_boost_data_default(), + pool, + ) + .await?; Ok(()) } diff --git a/mobile_verifier/tests/integrations/modeled_coverage.rs b/mobile_verifier/tests/integrations/modeled_coverage.rs index baa0e8c60..392801766 100644 --- a/mobile_verifier/tests/integrations/modeled_coverage.rs +++ b/mobile_verifier/tests/integrations/modeled_coverage.rs @@ -1,6 +1,5 @@ use crate::common; use chrono::{DateTime, Duration, Utc}; -use common::MockHexAssignments; use file_store::{ coverage::{CoverageObjectIngestReport, RadioHexSignalLevel}, heartbeat::{CbrsHeartbeat, CbrsHeartbeatIngestReport}, @@ -407,8 +406,12 @@ async fn process_input( transaction.commit().await?; let unassigned_hexes = UnassignedHex::fetch_unassigned(pool); - let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool) - .await?; + let _ = set_oracle_boosting_assignments( + unassigned_hexes, + &common::mock_hex_boost_data_default(), + pool, + ) + .await?; let mut transaction = pool.begin().await?; let mut heartbeats = pin!(ValidatedHeartbeat::validate_heartbeats( diff --git a/mobile_verifier/tests/integrations/rewarder_poc_dc.rs b/mobile_verifier/tests/integrations/rewarder_poc_dc.rs index daf7721b7..2812a06be 100644 --- a/mobile_verifier/tests/integrations/rewarder_poc_dc.rs +++ b/mobile_verifier/tests/integrations/rewarder_poc_dc.rs @@ -1,6 +1,5 @@ use crate::common::{self, MockFileSinkReceiver, MockHexBoostingClient}; use chrono::{DateTime, Duration as ChronoDuration, Utc}; -use common::MockHexAssignments; use file_store::{ coverage::{CoverageObject as FSCoverageObject, KeyType, RadioHexSignalLevel}, speedtest::CellSpeedtest, @@ -268,8 +267,12 @@ async fn seed_heartbeats( async fn update_assignments(pool: &PgPool) -> anyhow::Result<()> { let unassigned_hexes = UnassignedHex::fetch_unassigned(pool); - let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool) - .await?; + let _ = set_oracle_boosting_assignments( + unassigned_hexes, + &common::mock_hex_boost_data_default(), + pool, + ) + .await?; Ok(()) }