diff --git a/boost_manager/src/activator.rs b/boost_manager/src/activator.rs index bfa5958f0..796a772d4 100644 --- a/boost_manager/src/activator.rs +++ b/boost_manager/src/activator.rs @@ -6,14 +6,11 @@ use file_store::{ }; use futures::{future::LocalBoxFuture, stream, StreamExt, TryFutureExt, TryStreamExt}; use helium_proto::{ - services::poc_mobile::{ - mobile_reward_share::Reward as MobileReward, BoostedHex as BoostedHexProto, - MobileRewardShare, - }, + services::poc_mobile::{mobile_reward_share::Reward as MobileReward, MobileRewardShare}, Message, }; use mobile_config::{ - boosted_hex_info::BoostedHexes, + boosted_hex_info::{BoostedHex, BoostedHexes}, client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}, }; use poc_metrics::record_duration; @@ -118,7 +115,8 @@ where let share = MobileRewardShare::decode(msg)?; if let Some(MobileReward::RadioReward(r)) = share.reward { for hex in r.boosted_hexes.into_iter() { - process_boosted_hex(txn, manifest_time, &boosted_hexes, &hex).await? + process_boosted_hex(txn, manifest_time, &boosted_hexes, &hex.try_into()?) + .await? } } } @@ -130,14 +128,14 @@ pub async fn process_boosted_hex( txn: &mut Transaction<'_, Postgres>, manifest_time: DateTime, boosted_hexes: &BoostedHexes, - hex: &BoostedHexProto, + hex: &BoostedHex, ) -> Result<()> { match boosted_hexes.hexes.get(&hex.location) { Some(info) => { if info.start_ts.is_none() { db::insert_activated_hex( txn, - hex.location, + hex.location.into_raw(), &info.boosted_hex_pubkey.to_string(), &info.boost_config_pubkey.to_string(), manifest_time, diff --git a/boost_manager/tests/activator_tests.rs b/boost_manager/tests/activator_tests.rs index 34dff1310..2583f5241 100644 --- a/boost_manager/tests/activator_tests.rs +++ b/boost_manager/tests/activator_tests.rs @@ -1,8 +1,7 @@ mod common; use boost_manager::{activator, db, OnChainStatus}; use chrono::{DateTime, Duration as ChronoDuration, Duration, Timelike, Utc}; -use helium_proto::services::poc_mobile::BoostedHex as BoostedHexProto; -use mobile_config::boosted_hex_info::{BoostedHexInfo, BoostedHexes}; +use mobile_config::boosted_hex_info::{BoostedHex, BoostedHexInfo, BoostedHexes}; use solana_sdk::pubkey::Pubkey; use sqlx::PgPool; use std::{collections::HashMap, num::NonZeroU32, str::FromStr}; @@ -44,7 +43,7 @@ impl TestContext { let boosts = vec![ BoostedHexInfo { - location: 0x8a1fb466d2dffff_u64, + location: 0x8a1fb466d2dffff_u64.try_into().expect("valid h3 cell"), start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -54,7 +53,7 @@ impl TestContext { version: 0, }, BoostedHexInfo { - location: 0x8a1fb49642dffff_u64, + location: 0x8a1fb49642dffff_u64.try_into().expect("valid h3 cell"), start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -65,7 +64,7 @@ impl TestContext { }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: 0x8c2681a306607ff_u64.try_into().expect("valid h3 cell"), start_ts: None, end_ts: None, period_length: boost_period_length, @@ -101,9 +100,9 @@ async fn test_activated_hex_insert(pool: PgPool) -> anyhow::Result<()> { &mut txn, now, &boosted_hexes, - &BoostedHexProto { - location: 0x8c2681a306607ff_u64, - multiplier: 10, + &BoostedHex { + location: 0x8c2681a306607ff_u64.try_into().expect("valid h3 cell"), + multiplier: NonZeroU32::new(10).unwrap(), }, ) .await?; @@ -138,9 +137,9 @@ async fn test_activated_hex_no_insert(pool: PgPool) -> anyhow::Result<()> { &mut txn, now, &boosted_hexes, - &BoostedHexProto { - location: 0x8a1fb49642dffff_u64, - multiplier: 10, + &BoostedHex { + location: 0x8a1fb49642dffff_u64.try_into().expect("valid h3 cell"), + multiplier: NonZeroU32::new(10).unwrap(), }, ) .await?; @@ -172,9 +171,9 @@ async fn test_activated_dup_hex_insert(pool: PgPool) -> anyhow::Result<()> { &mut txn, now, &boosted_hexes, - &BoostedHexProto { - location: 0x8c2681a306607ff_u64, - multiplier: 10, + &BoostedHex { + location: 0x8c2681a306607ff_u64.try_into().expect("valid h3 cell"), + multiplier: NonZeroU32::new(10).unwrap(), }, ) .await?; @@ -183,9 +182,9 @@ async fn test_activated_dup_hex_insert(pool: PgPool) -> anyhow::Result<()> { &mut txn, now - ChronoDuration::days(1), &boosted_hexes, - &BoostedHexProto { - location: 0x8c2681a306607ff_u64, - multiplier: 5, + &BoostedHex { + location: 0x8c2681a306607ff_u64.try_into().expect("valid h3 cell"), + multiplier: NonZeroU32::new(5).unwrap(), }, ) .await?; diff --git a/boost_manager/tests/watcher_tests.rs b/boost_manager/tests/watcher_tests.rs index 185b1166e..f6dd9bad6 100644 --- a/boost_manager/tests/watcher_tests.rs +++ b/boost_manager/tests/watcher_tests.rs @@ -65,7 +65,7 @@ async fn test_boosted_hex_updates_to_filestore(pool: PgPool) -> anyhow::Result<( let boosted_hexes = vec![ BoostedHexInfo { - location: 0x8a1fb466d2dffff_u64, + location: 0x8a1fb466d2dffff_u64.try_into().expect("valid h3 cell"), start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -75,7 +75,7 @@ async fn test_boosted_hex_updates_to_filestore(pool: PgPool) -> anyhow::Result<( version: 0, }, BoostedHexInfo { - location: 0x8a1fb49642dffff_u64, + location: 0x8a1fb49642dffff_u64.try_into().expect("valid h3 cell"), start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, diff --git a/mobile_config/src/boosted_hex_info.rs b/mobile_config/src/boosted_hex_info.rs index 7dcf3649f..6a745e346 100644 --- a/mobile_config/src/boosted_hex_info.rs +++ b/mobile_config/src/boosted_hex_info.rs @@ -2,7 +2,9 @@ use crate::client::{hex_boosting_client::HexBoostingInfoResolver, ClientError}; use chrono::{DateTime, Duration, Utc}; use file_store::traits::TimestampDecode; use futures::stream::{BoxStream, StreamExt}; +use helium_proto::services::poc_mobile::BoostedHex as BoostedHexProto; use helium_proto::BoostedHexInfoV1 as BoostedHexInfoProto; +use hextree::Cell; use solana_sdk::pubkey::Pubkey; use std::{collections::HashMap, convert::TryFrom, num::NonZeroU32}; @@ -14,7 +16,7 @@ lazy_static::lazy_static! { #[derive(Clone, Debug)] pub struct BoostedHexInfo { - pub location: u64, + pub location: Cell, pub start_ts: Option>, pub end_ts: Option>, pub period_length: Duration, @@ -39,7 +41,7 @@ impl TryFrom for BoostedHexInfo { let boosted_hex_pubkey: Pubkey = Pubkey::try_from(v.boosted_hex_pubkey.as_slice())?; let boost_config_pubkey: Pubkey = Pubkey::try_from(v.boost_config_pubkey.as_slice())?; Ok(Self { - location: v.location, + location: v.location.try_into()?, start_ts, end_ts, period_length, @@ -63,7 +65,7 @@ impl TryFrom for BoostedHexInfoProto { .map(|v| v.get()) .collect::>(); Ok(Self { - location: v.location, + location: v.location.into_raw(), start_ts, end_ts, period_length: v.period_length.num_seconds() as u32, @@ -102,15 +104,30 @@ impl BoostedHexInfo { #[derive(Debug, Clone, Default)] pub struct BoostedHexes { - pub hexes: HashMap, + pub hexes: HashMap, } #[derive(PartialEq, Debug, Clone)] pub struct BoostedHex { - pub location: u64, + pub location: Cell, pub multiplier: NonZeroU32, } +impl TryFrom for BoostedHex { + type Error = anyhow::Error; + + fn try_from(value: BoostedHexProto) -> Result { + let location = Cell::from_raw(value.location)?; + let multiplier = NonZeroU32::new(value.multiplier) + .ok_or_else(|| anyhow::anyhow!("multiplier cannot be 0"))?; + + Ok(Self { + location, + multiplier, + }) + } +} + impl BoostedHexes { pub fn new(hexes: Vec) -> Self { let hexes = hexes @@ -134,7 +151,7 @@ impl BoostedHexes { Ok(Self { hexes: map }) } - pub fn is_boosted(&self, location: &u64) -> bool { + pub fn is_boosted(&self, location: &Cell) -> bool { self.hexes.contains_key(location) } @@ -153,7 +170,7 @@ impl BoostedHexes { Ok(Self { hexes: map }) } - pub fn get_current_multiplier(&self, location: u64, ts: DateTime) -> Option { + pub fn get_current_multiplier(&self, location: Cell, ts: DateTime) -> Option { self.hexes .get(&location) .and_then(|info| info.current_multiplier(ts).ok()?) @@ -164,6 +181,7 @@ pub(crate) mod db { use super::{to_end_ts, to_start_ts, BoostedHexInfo}; use chrono::{DateTime, Duration, Utc}; use futures::stream::{Stream, StreamExt}; + use hextree::Cell; use solana_sdk::pubkey::Pubkey; use sqlx::{PgExecutor, Row}; use std::num::NonZeroU32; @@ -236,8 +254,12 @@ pub(crate) mod db { let boosted_hex_pubkey = Pubkey::from_str(row.get::<&str, &str>("boosted_hex_pubkey")) .map_err(|e| sqlx::Error::Decode(Box::new(e)))?; let version = row.get::("version") as u32; + + let location = Cell::try_from(row.get::("location")) + .map_err(|e| sqlx::Error::Decode(Box::new(e)))?; + Ok(Self { - location: row.get::("location") as u64, + location, start_ts, end_ts, period_length, @@ -270,6 +292,7 @@ fn to_end_ts( mod tests { use super::*; use chrono::NaiveDateTime; + use hextree::Cell; use std::str::FromStr; const BOOST_HEX_PUBKEY: &str = "J9JiLTpjaShxL8eMvUs8txVw6TZ36E38SiJ89NxnMbLU"; @@ -295,7 +318,7 @@ mod tests { }; let msg = BoostedHexInfo::try_from(proto)?; - assert_eq!(631252734740306943, msg.location); + assert_eq!(Cell::from_raw(631252734740306943)?, msg.location); assert_eq!(None, msg.start_ts); assert_eq!(None, msg.end_ts); assert_eq!(2592000, msg.period_length.num_seconds()); @@ -336,7 +359,7 @@ mod tests { }; let msg = BoostedHexInfo::try_from(proto)?; - assert_eq!(631252734740306943, msg.location); + assert_eq!(Cell::from_raw(631252734740306943)?, msg.location); assert_eq!(parse_dt("2024-03-14 01:00:00"), msg.start_ts.unwrap()); assert_eq!(parse_dt("2024-07-12 01:00:00"), msg.end_ts.unwrap()); assert_eq!(2592000, msg.period_length.num_seconds()); diff --git a/mobile_verifier/src/coverage.rs b/mobile_verifier/src/coverage.rs index 8a47caa12..d7bcab615 100644 --- a/mobile_verifier/src/coverage.rs +++ b/mobile_verifier/src/coverage.rs @@ -25,6 +25,7 @@ use helium_proto::services::{ SignalLevel as SignalLevelProto, }, }; +use hextree::Cell; use mobile_config::{ boosted_hex_info::{BoostedHex, BoostedHexes}, client::AuthorizationClient, @@ -240,7 +241,7 @@ async fn initialize_unassigned_hexes( let hexes: anyhow::Result> = hexes .into_iter() .map(|hex| { - let cell = hextree::Cell::from_raw(hex.hex)?; + let cell = Cell::from_raw(hex.hex)?; let urbanized = hex_boost_data.urbanization.assignment(cell)?; let footfall = hex_boost_data.footfall.assignment(cell)?; @@ -444,7 +445,8 @@ impl CoverageObject { #[derive(Clone, FromRow)] pub struct HexCoverage { pub uuid: Uuid, - pub hex: i64, + #[sqlx(try_from = "i64")] + pub hex: Cell, pub indoor: bool, pub radio_key: OwnedKeyType, pub signal_level: SignalLevel, @@ -701,12 +703,15 @@ pub async fn clear_coverage_objects( Ok(()) } +type IndoorCellTree = HashMap>>; +type OutdoorCellTree = HashMap>; + #[derive(Default, Debug)] pub struct CoveredHexes { - indoor_cbrs: HashMap>>, - indoor_wifi: HashMap>>, - outdoor_cbrs: HashMap>, - outdoor_wifi: HashMap>, + indoor_cbrs: IndoorCellTree, + indoor_wifi: IndoorCellTree, + outdoor_cbrs: OutdoorCellTree, + outdoor_wifi: OutdoorCellTree, } pub const MAX_INDOOR_RADIOS_PER_RES12_HEX: usize = 1; @@ -725,7 +730,7 @@ impl CoveredHexes { let mut boosted = false; while let Some(hex_coverage) = covered_hexes.next().await.transpose()? { - boosted |= boosted_hexes.is_boosted(&(hex_coverage.hex as u64)); + boosted |= boosted_hexes.is_boosted(&hex_coverage.hex); match (hex_coverage.indoor, &hex_coverage.radio_key) { (true, OwnedKeyType::Cbrs(_)) => { insert_indoor_coverage(&mut self.indoor_cbrs, hotspot, hex_coverage); @@ -769,12 +774,12 @@ impl CoveredHexes { } fn insert_indoor_coverage( - indoor: &mut HashMap>>, + indoor: &mut IndoorCellTree, hotspot: &PublicKeyBinary, hex_coverage: HexCoverage, ) { indoor - .entry(CellIndex::try_from(hex_coverage.hex as u64).unwrap()) + .entry(hex_coverage.hex) .or_default() .entry(hex_coverage.signal_level) .or_default() @@ -789,12 +794,12 @@ fn insert_indoor_coverage( } fn insert_outdoor_coverage( - outdoor: &mut HashMap>, + outdoor: &mut OutdoorCellTree, hotspot: &PublicKeyBinary, hex_coverage: HexCoverage, ) { outdoor - .entry(CellIndex::try_from(hex_coverage.hex as u64).unwrap()) + .entry(hex_coverage.hex) .or_default() .push(OutdoorCoverageLevel { radio_key: hex_coverage.radio_key, @@ -808,7 +813,7 @@ fn insert_outdoor_coverage( } fn into_outdoor_rewards( - outdoor: HashMap>, + outdoor: OutdoorCellTree, boosted_hexes: &BoostedHexes, epoch_start: DateTime, ) -> impl Iterator + '_ { @@ -820,7 +825,7 @@ fn into_outdoor_rewards( .zip(OUTDOOR_REWARD_WEIGHTS) .map(move |(cl, rank)| { let boost_multiplier = boosted_hexes - .get_current_multiplier(hex.into(), epoch_start) + .get_current_multiplier(hex, epoch_start) .unwrap_or(NonZeroU32::new(1).unwrap()); CoverageReward { @@ -834,7 +839,7 @@ fn into_outdoor_rewards( hotspot: cl.hotspot, radio_key: cl.radio_key, boosted_hex_info: BoostedHex { - location: hex.into(), + location: hex, multiplier: boost_multiplier, }, } @@ -843,7 +848,7 @@ fn into_outdoor_rewards( } fn into_indoor_rewards( - indoor: HashMap>>, + indoor: IndoorCellTree, boosted_hexes: &BoostedHexes, epoch_start: DateTime, ) -> impl Iterator + '_ { @@ -857,7 +862,7 @@ fn into_indoor_rewards( .take(MAX_INDOOR_RADIOS_PER_RES12_HEX) .map(move |cl| { let boost_multiplier = boosted_hexes - .get_current_multiplier(hex.into(), epoch_start) + .get_current_multiplier(hex, epoch_start) .unwrap_or(NonZeroU32::new(1).unwrap()); CoverageReward { @@ -871,7 +876,7 @@ fn into_indoor_rewards( hotspot: cl.hotspot, radio_key: cl.radio_key, boosted_hex_info: BoostedHex { - location: hex.into(), + location: hex, multiplier: boost_multiplier, }, } @@ -1043,6 +1048,7 @@ mod test { use super::*; use chrono::NaiveDate; use futures::stream::iter; + use hextree::Cell; /// Test to ensure that if there are multiple radios with different signal levels /// in a given hex, that the one with the highest signal level is chosen. @@ -1082,7 +1088,7 @@ mod test { rank: None }, boosted_hex_info: BoostedHex { - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, }] @@ -1104,7 +1110,7 @@ mod test { ) -> HexCoverage { HexCoverage { uuid: Uuid::new_v4(), - hex: 0x8a1fb46622dffff_u64 as i64, + hex: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), indoor: true, radio_key: OwnedKeyType::Cbrs(cbsd_id.to_string()), signal_level, @@ -1200,7 +1206,7 @@ mod test { rank: None }, boosted_hex_info: BoostedHex { - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, }] @@ -1244,7 +1250,7 @@ mod test { footfall: Assignment::A }, boosted_hex_info: BoostedHex { - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, }, @@ -1259,7 +1265,7 @@ mod test { footfall: Assignment::A }, boosted_hex_info: BoostedHex { - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, }, @@ -1274,7 +1280,7 @@ mod test { footfall: Assignment::A }, boosted_hex_info: BoostedHex { - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, } @@ -1534,7 +1540,7 @@ mod test { ) -> HexCoverage { HexCoverage { uuid: Uuid::new_v4(), - hex: 0x8a1fb46622dffff_u64 as i64, + hex: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), indoor: true, radio_key: OwnedKeyType::Cbrs(cbsd_id.to_string()), signal_level, @@ -1554,7 +1560,7 @@ mod test { ) -> HexCoverage { HexCoverage { uuid: Uuid::new_v4(), - hex: 0x8a1fb46622dffff_u64 as i64, + hex: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), indoor: false, radio_key: OwnedKeyType::Cbrs(cbsd_id.to_string()), signal_power, @@ -1573,7 +1579,7 @@ mod test { ) -> HexCoverage { HexCoverage { uuid: Uuid::new_v4(), - hex: 0x8a1fb46622dffff_u64 as i64, + hex: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), indoor: false, radio_key: OwnedKeyType::Wifi(hotspot_key.clone()), signal_power, @@ -1592,7 +1598,7 @@ mod test { ) -> HexCoverage { HexCoverage { uuid: Uuid::new_v4(), - hex: 0x8a1fb46622dffff_u64 as i64, + hex: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), indoor: true, radio_key: OwnedKeyType::Wifi(hotspot_key.clone()), signal_power: 0, diff --git a/mobile_verifier/src/reward_shares.rs b/mobile_verifier/src/reward_shares.rs index b152682f1..586fd4d5b 100644 --- a/mobile_verifier/src/reward_shares.rs +++ b/mobile_verifier/src/reward_shares.rs @@ -640,7 +640,7 @@ fn new_radio_reward( .iter() .filter(|radio_points| radio_points.boosted_hex.multiplier > NonZeroU32::new(1).unwrap()) .map(|radio_points| proto::BoostedHex { - location: radio_points.boosted_hex.location, + location: radio_points.boosted_hex.location.into_raw(), multiplier: radio_points.boosted_hex.multiplier.get(), }) .collect(); @@ -714,6 +714,7 @@ mod test { use helium_proto::{ services::poc_mobile::mobile_reward_share::Reward as MobileReward, ServiceProvider, }; + use hextree::Cell; use prost::Message; use std::collections::HashMap; use uuid::Uuid; @@ -995,9 +996,11 @@ mod test { fn simple_hex_coverage<'a>(key: impl Into>, hex: u64) -> Vec { let key = key.into(); let radio_key = key.to_owned(); + let hex = hex.try_into().expect("valid h3 cell"); + vec![HexCoverage { uuid: Uuid::new_v4(), - hex: hex as i64, + hex, indoor: true, radio_key, signal_level: crate::coverage::SignalLevel::Low, @@ -1895,7 +1898,7 @@ mod test { rank: None, }, boosted_hex: BoostedHex { - location: 0, + location: Cell::from_raw(0x8a1fb46622dffff).expect("valid h3 cell"), multiplier: NonZeroU32::new(1).unwrap(), }, }], diff --git a/mobile_verifier/tests/hex_boosting.rs b/mobile_verifier/tests/hex_boosting.rs index e57708ef6..c9a1dd09d 100644 --- a/mobile_verifier/tests/hex_boosting.rs +++ b/mobile_verifier/tests/hex_boosting.rs @@ -13,6 +13,7 @@ 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}, @@ -123,7 +124,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { let boosted_hexes = vec![ BoostedHexInfo { // hotspot 1's location - location: 0x8a1fb466d2dffff_u64, + location: Cell::from_raw(0x8a1fb466d2dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -134,7 +135,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { }, BoostedHexInfo { // hotspot 2's location - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff_u64)?, start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -145,7 +146,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff_u64)?, start_ts: None, end_ts: None, period_length: boost_period_length, @@ -291,7 +292,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu let boosted_hexes = vec![ BoostedHexInfo { // hotspot 1's location - location: 0x8a1fb466d2dffff_u64, + location: Cell::from_raw(0x8a1fb466d2dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -302,7 +303,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu }, BoostedHexInfo { // hotspot 2's location - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff_u64)?, start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -313,7 +314,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff_u64)?, start_ts: None, end_ts: None, period_length: boost_period_length, @@ -439,7 +440,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res let boosted_hexes = vec![ BoostedHexInfo { // hotspot 1's first covered location - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -450,7 +451,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res }, BoostedHexInfo { // hotspot 1's second covered location - location: 0x8a1fb46622d7fff_u64, + location: Cell::from_raw(0x8a1fb46622d7fff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -461,7 +462,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res }, BoostedHexInfo { // hotspot 2's location - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff_u64)?, start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -472,7 +473,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff_u64)?, start_ts: Some(start_ts_3), end_ts: Some(end_ts_3), period_length: boost_period_length, @@ -610,7 +611,7 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { let boosted_hexes = vec![ BoostedHexInfo { - location: 0x8a1fb466d2dffff_u64, + location: Cell::from_raw(0x8a1fb466d2dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -620,7 +621,7 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { version: 0, }, BoostedHexInfo { - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff_u64)?, start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -721,7 +722,7 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: let boosted_hexes = vec![ BoostedHexInfo { // hotspot 1's location - location: 0x8a1fb466d2dffff_u64, + location: Cell::from_raw(0x8a1fb466d2dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -732,7 +733,7 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff_u64)?, start_ts: None, end_ts: None, period_length: boost_period_length, @@ -885,7 +886,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an let boosted_hexes = vec![ BoostedHexInfo { // hotspot 1's first covered location - location: 0x8a1fb46622dffff_u64, + location: Cell::from_raw(0x8a1fb46622dffff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -896,7 +897,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an }, BoostedHexInfo { // hotspot 1's second covered location - location: 0x8a1fb46622d7fff_u64, + location: Cell::from_raw(0x8a1fb46622d7fff_u64)?, start_ts: Some(start_ts_1), end_ts: Some(end_ts_1), period_length: boost_period_length, @@ -907,7 +908,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an }, BoostedHexInfo { // hotspot 2's location - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff_u64)?, start_ts: Some(start_ts_2), end_ts: Some(end_ts_2), period_length: boost_period_length, @@ -918,7 +919,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an }, BoostedHexInfo { // hotspot 3's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff_u64)?, start_ts: Some(start_ts_3), end_ts: Some(end_ts_3), period_length: boost_period_length, diff --git a/mobile_verifier/tests/modeled_coverage.rs b/mobile_verifier/tests/modeled_coverage.rs index 0a40b0f22..e5dad0c15 100644 --- a/mobile_verifier/tests/modeled_coverage.rs +++ b/mobile_verifier/tests/modeled_coverage.rs @@ -12,6 +12,7 @@ use helium_proto::services::{ mobile_config::NetworkKeyRole, poc_mobile::{CoverageObjectValidity, SignalLevel}, }; +use hextree::Cell; use mobile_config::boosted_hex_info::{BoostedHexInfo, BoostedHexes}; use mobile_verifier::{ @@ -845,9 +846,9 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { let mut boosted_hexes = BoostedHexes::default(); boosted_hexes.hexes.insert( - 0x8a1fb466d2dffff_u64, + Cell::from_raw(0x8a1fb466d2dffff)?, BoostedHexInfo { - location: 0x8a1fb466d2dffff_u64, + location: Cell::from_raw(0x8a1fb466d2dffff)?, start_ts: None, end_ts: None, period_length: Duration::hours(1), @@ -858,9 +859,9 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { }, ); boosted_hexes.hexes.insert( - 0x8a1fb49642dffff_u64, + Cell::from_raw(0x8a1fb49642dffff)?, BoostedHexInfo { - location: 0x8a1fb49642dffff_u64, + location: Cell::from_raw(0x8a1fb49642dffff)?, start_ts: None, end_ts: None, period_length: Duration::hours(1), @@ -871,10 +872,10 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> { }, ); boosted_hexes.hexes.insert( - 0x8c2681a306607ff_u64, + Cell::from_raw(0x8c2681a306607ff)?, BoostedHexInfo { // hotspot 1's location - location: 0x8c2681a306607ff_u64, + location: Cell::from_raw(0x8c2681a306607ff)?, start_ts: None, end_ts: None, period_length: Duration::hours(1),