diff --git a/boost_manager/tests/common/mod.rs b/boost_manager/tests/common/mod.rs index 1c5d267b1..ca30b3b70 100644 --- a/boost_manager/tests/common/mod.rs +++ b/boost_manager/tests/common/mod.rs @@ -2,14 +2,8 @@ use file_store::file_sink::{FileSinkClient, Message as SinkMessage}; use helium_proto::BoostedHexInfoV1 as BoostedHexInfoProto; use helium_proto::BoostedHexUpdateV1 as BoostedHexUpdateProto; use helium_proto::Message; -use mobile_config::boosted_hex_info::BoostedHexInfo; use tokio::{sync::mpsc::error::TryRecvError, time::timeout}; -#[derive(Debug, Clone)] -pub struct MockHexBoostingClient { - pub boosted_hexes: Vec, -} - pub struct MockFileSinkReceiver { pub receiver: tokio::sync::mpsc::Receiver, } diff --git a/boost_manager/tests/watcher_tests.rs b/boost_manager/tests/watcher_tests.rs index f6dd9bad6..433df6982 100644 --- a/boost_manager/tests/watcher_tests.rs +++ b/boost_manager/tests/watcher_tests.rs @@ -1,5 +1,5 @@ mod common; -use crate::common::{MockFileSinkReceiver, MockHexBoostingClient}; +use crate::common::MockFileSinkReceiver; use async_trait::async_trait; use boost_manager::watcher::{self, Watcher}; use chrono::{DateTime, Duration as ChronoDuration, Duration, Utc}; @@ -16,6 +16,11 @@ use std::{num::NonZeroU32, str::FromStr}; const BOOST_HEX_PUBKEY: &str = "J9JiLTpjaShxL8eMvUs8txVw6TZ36E38SiJ89NxnMbLU"; const BOOST_CONFIG_PUBKEY: &str = "BZM1QTud72B2cpTW7PhEnFmRX7ZWzvY7DpPpNJJuDrWG"; +#[derive(Debug, Clone)] +pub struct MockHexBoostingClient { + pub boosted_hexes: Vec, +} + impl MockHexBoostingClient { fn new(boosted_hexes: Vec) -> Self { Self { boosted_hexes } diff --git a/mobile_verifier/tests/common/mod.rs b/mobile_verifier/tests/common/mod.rs index e96ecc411..026c0b594 100644 --- a/mobile_verifier/tests/common/mod.rs +++ b/mobile_verifier/tests/common/mod.rs @@ -1,4 +1,6 @@ +use chrono::{DateTime, Utc}; use file_store::file_sink::{FileSinkClient, Message as SinkMessage}; +use futures::{stream, StreamExt}; use helium_proto::{ services::poc_mobile::{ mobile_reward_share::Reward as MobileReward, GatewayReward, MobileRewardShare, RadioReward, @@ -6,21 +8,42 @@ use helium_proto::{ }, Message, }; -use mobile_config::boosted_hex_info::BoostedHexInfo; +use mobile_config::{ + boosted_hex_info::{BoostedHexInfo, BoostedHexInfoStream}, + client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, +}; use mobile_verifier::boosting_oracles::{Assignment, BoostedHexAssignments, HexAssignments}; use std::collections::HashMap; use tokio::{sync::mpsc::error::TryRecvError, time::timeout}; - -pub type ValidSpMap = HashMap; +use tonic::async_trait; #[derive(Debug, Clone)] -pub struct MockCarrierServiceClient { - pub valid_sps: ValidSpMap, +pub struct MockHexBoostingClient { + boosted_hexes: Vec, } -#[derive(Debug, Clone)] -pub struct MockHexBoostingClient { - pub boosted_hexes: Vec, +// this fn is actually used but clippy is unhappy bc it's only used in tests... +#[allow(dead_code)] +impl MockHexBoostingClient { + pub fn new(boosted_hexes: Vec) -> Self { + Self { boosted_hexes } + } +} + +#[async_trait] +impl HexBoostingInfoResolver for MockHexBoostingClient { + type Error = ClientError; + + async fn stream_boosted_hexes_info(&mut self) -> Result { + Ok(stream::iter(self.boosted_hexes.clone()).boxed()) + } + + async fn stream_modified_boosted_hexes_info( + &mut self, + _timestamp: DateTime, + ) -> Result { + Ok(stream::iter(self.boosted_hexes.clone()).boxed()) + } } pub struct MockFileSinkReceiver { diff --git a/mobile_verifier/tests/hex_boosting.rs b/mobile_verifier/tests/hex_boosting.rs index 22035a9bc..c85ad0dd1 100644 --- a/mobile_verifier/tests/hex_boosting.rs +++ b/mobile_verifier/tests/hex_boosting.rs @@ -1,23 +1,19 @@ mod common; -use crate::common::{MockFileSinkReceiver, MockHexBoostingClient}; -use async_trait::async_trait; +use crate::common::MockFileSinkReceiver; use chrono::{DateTime, Duration as ChronoDuration, Duration, Utc}; +use common::MockHexBoostingClient; use file_store::{ coverage::{CoverageObject as FSCoverageObject, KeyType, RadioHexSignalLevel}, mobile_radio_threshold::{RadioThresholdIngestReport, RadioThresholdReportReq}, speedtest::CellSpeedtest, }; -use futures_util::{stream, StreamExt as FuturesStreamExt}; use helium_crypto::PublicKeyBinary; use helium_proto::services::poc_mobile::{ CoverageObjectValidity, HeartbeatValidity, RadioReward, SeniorityUpdateReason, SignalLevel, UnallocatedReward, }; use hextree::Cell; -use mobile_config::{ - boosted_hex_info::{BoostedHexInfo, BoostedHexInfoStream}, - client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, -}; +use mobile_config::boosted_hex_info::BoostedHexInfo; use mobile_verifier::{ cell_type::CellType, coverage::{set_oracle_boosting_assignments, CoverageObject, UnassignedHex}, @@ -39,28 +35,6 @@ const CARRIER_HOTSPOT_KEY: &str = "11hd7HoicRgBPjBGcqcT2Y9hRQovdZeff5eKFMbCSuDYQ const BOOST_HEX_PUBKEY: &str = "J9JiLTpjaShxL8eMvUs8txVw6TZ36E38SiJ89NxnMbLU"; const BOOST_CONFIG_PUBKEY: &str = "BZM1QTud72B2cpTW7PhEnFmRX7ZWzvY7DpPpNJJuDrWG"; -impl MockHexBoostingClient { - fn new(boosted_hexes: Vec) -> Self { - Self { boosted_hexes } - } -} - -#[async_trait] -impl HexBoostingInfoResolver for MockHexBoostingClient { - type Error = ClientError; - - async fn stream_boosted_hexes_info(&mut self) -> Result { - Ok(stream::iter(self.boosted_hexes.clone()).boxed()) - } - - async fn stream_modified_boosted_hexes_info( - &mut self, - _timestamp: DateTime, - ) -> Result { - Ok(stream::iter(self.boosted_hexes.clone()).boxed()) - } -} - async fn update_assignments(pool: &PgPool) -> anyhow::Result<()> { let unassigned_hexes = UnassignedHex::fetch(pool); let _ = set_oracle_boosting_assignments( diff --git a/mobile_verifier/tests/rewarder_poc_dc.rs b/mobile_verifier/tests/rewarder_poc_dc.rs index 2928310b3..842c4979b 100644 --- a/mobile_verifier/tests/rewarder_poc_dc.rs +++ b/mobile_verifier/tests/rewarder_poc_dc.rs @@ -1,26 +1,19 @@ mod common; use crate::common::{MockFileSinkReceiver, MockHexBoostingClient}; -use async_trait::async_trait; use chrono::{DateTime, Duration as ChronoDuration, Utc}; use file_store::{ coverage::{CoverageObject as FSCoverageObject, KeyType, RadioHexSignalLevel}, speedtest::CellSpeedtest, }; -use futures_util::{stream, StreamExt as FuturesStreamExt}; use helium_crypto::PublicKeyBinary; use helium_proto::services::poc_mobile::{ CoverageObjectValidity, GatewayReward, HeartbeatValidity, RadioReward, SeniorityUpdateReason, SignalLevel, UnallocatedReward, UnallocatedRewardType, }; -use mobile_config::{ - boosted_hex_info::{BoostedHexInfo, BoostedHexInfoStream}, - client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, -}; use mobile_verifier::{ cell_type::CellType, coverage::{set_oracle_boosting_assignments, CoverageObject, UnassignedHex}, data_session, - geofence::GeofenceValidator, heartbeats::{HbType, Heartbeat, ValidatedHeartbeat}, reward_shares, rewarder, speedtests, }; @@ -33,38 +26,6 @@ const HOTSPOT_1: &str = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6"; const HOTSPOT_2: &str = "11uJHS2YaEWJqgqC7yza9uvSmpv5FWoMQXiP8WbxBGgNUmifUJf"; const HOTSPOT_3: &str = "112E7TxoNHV46M6tiPA8N1MkeMeQxc9ztb4JQLXBVAAUfq1kJLoF"; const PAYER_1: &str = "11eX55faMbqZB7jzN4p67m6w7ScPMH6ubnvCjCPLh72J49PaJEL"; - -impl MockHexBoostingClient { - fn new(boosted_hexes: Vec) -> Self { - Self { boosted_hexes } - } -} - -#[async_trait] -impl HexBoostingInfoResolver for MockHexBoostingClient { - type Error = ClientError; - - async fn stream_boosted_hexes_info(&mut self) -> Result { - Ok(stream::iter(self.boosted_hexes.clone()).boxed()) - } - - async fn stream_modified_boosted_hexes_info( - &mut self, - _timestamp: DateTime, - ) -> Result { - Ok(stream::iter(self.boosted_hexes.clone()).boxed()) - } -} - -#[derive(Clone)] -struct MockGeofence; - -impl GeofenceValidator for MockGeofence { - fn in_valid_region(&self, _cell: &hextree::Cell) -> bool { - true - } -} - #[sqlx::test] async fn test_poc_and_dc_rewards(pool: PgPool) -> anyhow::Result<()> { let (mobile_rewards_client, mut mobile_rewards) = common::create_file_sink(); diff --git a/mobile_verifier/tests/rewarder_sp_rewards.rs b/mobile_verifier/tests/rewarder_sp_rewards.rs index 5f3c5e2e0..2752174a7 100644 --- a/mobile_verifier/tests/rewarder_sp_rewards.rs +++ b/mobile_verifier/tests/rewarder_sp_rewards.rs @@ -11,8 +11,6 @@ use rust_decimal::prelude::*; use rust_decimal_macros::dec; use sqlx::{PgPool, Postgres, Transaction}; -use common::MockCarrierServiceClient; -use common::ValidSpMap; use mobile_config::client::{carrier_service_client::CarrierServiceVerifier, ClientError}; use mobile_verifier::{data_session, reward_shares, rewarder}; @@ -26,6 +24,13 @@ const PAYER_1: &str = "11uJHS2YaEWJqgqC7yza9uvSmpv5FWoMQXiP8WbxBGgNUmifUJf"; const PAYER_2: &str = "11sctWiP9r5wDJVuDe1Th4XSL2vaawaLLSQF8f8iokAoMAJHxqp"; const SP_1: &str = "Helium Mobile"; +pub type ValidSpMap = HashMap; + +#[derive(Debug, Clone)] +pub struct MockCarrierServiceClient { + pub valid_sps: ValidSpMap, +} + impl MockCarrierServiceClient { fn new(valid_sps: ValidSpMap) -> Self { Self { valid_sps }