From 203dffcec36b4aaa73c02c2d1be93d2b964868f1 Mon Sep 17 00:00:00 2001 From: Andrew McKenzie Date: Thu, 12 Dec 2024 11:53:02 +0000 Subject: [PATCH] rename some things --- mobile_config/src/client/sub_dao_client.rs | 11 ++-- mobile_config/src/lib.rs | 6 +- .../src/sub_dao_epoch_reward_info.rs | 8 +-- mobile_verifier/src/lib.rs | 24 ++++---- mobile_verifier/src/reward_shares.rs | 49 +++++++--------- mobile_verifier/src/rewarder.rs | 38 ++++++------ .../src/service_provider/reward.rs | 19 +++--- mobile_verifier/src/telemetry.rs | 4 +- .../tests/integrations/common/mod.rs | 13 ++--- .../tests/integrations/hex_boosting.rs | 58 +++++++++---------- .../tests/integrations/rewarder_poc_dc.rs | 10 ++-- 11 files changed, 113 insertions(+), 127 deletions(-) diff --git a/mobile_config/src/client/sub_dao_client.rs b/mobile_config/src/client/sub_dao_client.rs index dc23d0f52..3f89ea4c3 100644 --- a/mobile_config/src/client/sub_dao_client.rs +++ b/mobile_config/src/client/sub_dao_client.rs @@ -1,5 +1,5 @@ use super::{call_with_retry, ClientError, Settings}; -use crate::sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo; +use crate::sub_dao_epoch_reward_info::EpochRewardInfo; use file_store::traits::MsgVerify; use helium_crypto::{Keypair, PublicKey, Sign}; use helium_proto::{ @@ -36,7 +36,7 @@ pub trait SubDaoEpochRewardInfoResolver: Clone + Send + Sync + 'static { &self, sub_dao: &str, epoch: u64, - ) -> Result, Self::Error>; + ) -> Result, Self::Error>; } #[async_trait::async_trait] @@ -47,7 +47,7 @@ impl SubDaoEpochRewardInfoResolver for SubDaoClient { &self, sub_dao: &str, epoch: u64, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { let mut request = SubDaoEpochRewardInfoReqV1 { sub_dao_address: sub_dao.into(), epoch, @@ -64,10 +64,7 @@ impl SubDaoEpochRewardInfoResolver for SubDaoClient { Ok(info_res) => { let response = info_res.into_inner(); response.verify(&self.config_pubkey)?; - response - .info - .map(ResolvedSubDaoEpochRewardInfo::try_from) - .transpose()? + response.info.map(EpochRewardInfo::try_from).transpose()? } Err(status) if status.code() == tonic::Code::NotFound => None, Err(status) => Err(status)?, diff --git a/mobile_config/src/lib.rs b/mobile_config/src/lib.rs index 3e6d26729..fc81cae09 100644 --- a/mobile_config/src/lib.rs +++ b/mobile_config/src/lib.rs @@ -99,15 +99,15 @@ impl std::fmt::Display for KeyRole { } } -pub struct EpochPeriod { +pub struct EpochInfo { pub period: Range>, } -impl From for EpochPeriod { +impl From for EpochInfo { fn from(next_reward_epoch: u64) -> Self { let start_time = DateTime::::UNIX_EPOCH + Duration::days(next_reward_epoch as i64); let end_time = start_time + Duration::days(1); - EpochPeriod { + EpochInfo { period: start_time..end_time, } } diff --git a/mobile_config/src/sub_dao_epoch_reward_info.rs b/mobile_config/src/sub_dao_epoch_reward_info.rs index 699ccc38b..1481ed22b 100644 --- a/mobile_config/src/sub_dao_epoch_reward_info.rs +++ b/mobile_config/src/sub_dao_epoch_reward_info.rs @@ -1,4 +1,4 @@ -use crate::EpochPeriod; +use crate::EpochInfo; use chrono::{DateTime, Utc}; use file_store::traits::{TimestampDecode, TimestampEncode}; use helium_proto::services::sub_dao::SubDaoEpochRewardInfo as SubDaoEpochRewardInfoProto; @@ -6,7 +6,7 @@ use rust_decimal::prelude::*; use std::ops::Range; #[derive(Clone, Debug)] -pub struct ResolvedSubDaoEpochRewardInfo { +pub struct EpochRewardInfo { pub epoch_day: u64, pub epoch_address: String, pub sub_dao_address: String, @@ -44,11 +44,11 @@ impl From for SubDaoEpochRewardInfoProto { } } -impl TryFrom for ResolvedSubDaoEpochRewardInfo { +impl TryFrom for EpochRewardInfo { type Error = SubDaoRewardInfoParseError; fn try_from(info: SubDaoEpochRewardInfoProto) -> Result { - let epoch_period: EpochPeriod = info.epoch.into(); + let epoch_period: EpochInfo = info.epoch.into(); let epoch_rewards = Decimal::from(info.rewards_issued + info.delegation_rewards_issued); Ok(Self { diff --git a/mobile_verifier/src/lib.rs b/mobile_verifier/src/lib.rs index f97d43080..050ef25bb 100644 --- a/mobile_verifier/src/lib.rs +++ b/mobile_verifier/src/lib.rs @@ -101,22 +101,22 @@ impl IsAuthorized for mobile_config::client::AuthorizationClient { } #[derive(Clone, Debug)] -pub struct HntPrice { - pub hnt_price_in_bones: u64, - pub hnt_price: Decimal, - pub price_per_hnt_bone: Decimal, +pub struct PriceInfo { + pub price_in_bones: u64, + pub price_per_token: Decimal, + pub price_per_bone: Decimal, pub decimals: u8, } -impl HntPrice { - pub fn new(hnt_price_in_bones: u64, decimals: u8) -> Self { - let hnt_price = - Decimal::from(hnt_price_in_bones) / Decimal::from(10_u64.pow(decimals as u32)); - let price_per_hnt_bone = hnt_price / Decimal::from(10_u64.pow(decimals as u32)); +impl PriceInfo { + pub fn new(price_in_bones: u64, decimals: u8) -> Self { + let price_per_token = + Decimal::from(price_in_bones) / Decimal::from(10_u64.pow(decimals as u32)); + let price_per_bone = price_per_token / Decimal::from(10_u64.pow(decimals as u32)); Self { - hnt_price_in_bones, - hnt_price, - price_per_hnt_bone, + price_in_bones, + price_per_token, + price_per_bone, decimals, } } diff --git a/mobile_verifier/src/reward_shares.rs b/mobile_verifier/src/reward_shares.rs index a65c5d19d..43eb20533 100644 --- a/mobile_verifier/src/reward_shares.rs +++ b/mobile_verifier/src/reward_shares.rs @@ -3,7 +3,7 @@ use crate::{ rewarder::boosted_hex_eligibility::BoostedHexEligibility, seniority::Seniority, sp_boosted_rewards_bans::BannedRadios, speedtests_average::SpeedtestAverages, subscriber_location::SubscriberValidatedLocations, - subscriber_verified_mapping_event::VerifiedSubscriberVerifiedMappingEventShares, HntPrice, + subscriber_verified_mapping_event::VerifiedSubscriberVerifiedMappingEventShares, PriceInfo, }; use chrono::{DateTime, Utc}; use coverage_point_calculator::{OracleBoostingStatus, SPBoostedRewardEligibility}; @@ -13,9 +13,7 @@ use helium_crypto::PublicKeyBinary; use helium_proto::services::{ poc_mobile as proto, poc_mobile::mobile_reward_share::Reward as ProtoReward, }; -use mobile_config::{ - boosted_hex_info::BoostedHexes, sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo, -}; +use mobile_config::{boosted_hex_info::BoostedHexes, sub_dao_epoch_reward_info::EpochRewardInfo}; use radio_reward_v2::{RadioRewardV2Ext, ToProtoDecimal}; use rust_decimal::prelude::*; use rust_decimal_macros::dec; @@ -57,7 +55,7 @@ pub struct TransferRewards { reward_scale: Decimal, rewards: HashMap, reward_sum: Decimal, - hnt_price: HntPrice, + price_info: PriceInfo, } #[derive(Copy, Clone, Debug)] @@ -93,7 +91,7 @@ impl TransferRewards { } pub async fn from_transfer_sessions( - hnt_price: HntPrice, + price_info: PriceInfo, transfer_sessions: HotspotMap, reward_shares: &DataTransferAndPocAllocatedRewardBuckets, ) -> Self { @@ -104,7 +102,7 @@ impl TransferRewards { .map(|(pub_key, rewardable)| { let bones = dc_to_hnt_bones( Decimal::from(rewardable.rewardable_dc), - hnt_price.price_per_hnt_bone, + price_info.price_per_bone, ); reward_sum += bones; ( @@ -130,13 +128,13 @@ impl TransferRewards { reward_scale, rewards, reward_sum: reward_sum * reward_scale, - hnt_price, + price_info, } } pub fn into_rewards( self, - reward_info: &'_ ResolvedSubDaoEpochRewardInfo, + reward_info: &'_ EpochRewardInfo, ) -> impl Iterator + '_ { let Self { reward_scale, @@ -145,7 +143,7 @@ impl TransferRewards { } = self; let start_period = reward_info.epoch_period.start.encode_timestamp(); let end_period = reward_info.epoch_period.end.encode_timestamp(); - let price = self.hnt_price.hnt_price_in_bones; + let price = self.price_info.price_in_bones; rewards .into_iter() @@ -802,12 +800,9 @@ mod test { (hnt_value / DC_USD_PRICE).round_dp_with_strategy(0, RoundingStrategy::ToNegativeInfinity) } - fn default_rewards_info( - total_emissions: u64, - epoch_duration: Duration, - ) -> ResolvedSubDaoEpochRewardInfo { + fn default_rewards_info(total_emissions: u64, epoch_duration: Duration) -> EpochRewardInfo { let now = Utc::now(); - ResolvedSubDaoEpochRewardInfo { + EpochRewardInfo { epoch_day: 1, epoch_address: EPOCH_ADDRESS.into(), sub_dao_address: SUB_DAO_ADDRESS.into(), @@ -958,12 +953,12 @@ mod test { DataTransferAndPocAllocatedRewardBuckets::new(rewards_info.epoch_emissions); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let data_transfer_rewards = - TransferRewards::from_transfer_sessions(hnt_price, data_transfer_map, &reward_shares) + TransferRewards::from_transfer_sessions(price_info, data_transfer_map, &reward_shares) .await; assert_eq!(data_transfer_rewards.reward(&owner), dec!(0.00002)); @@ -1011,15 +1006,15 @@ mod test { let rewards_info = default_rewards_info(82_191_780_821_917, Duration::hours(24)); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let reward_shares = DataTransferAndPocAllocatedRewardBuckets::new(rewards_info.epoch_emissions); let data_transfer_rewards = TransferRewards::from_transfer_sessions( - hnt_price, + price_info, aggregated_data_transfer_sessions, &reward_shares, ) @@ -2435,10 +2430,10 @@ mod test { let hnt_dollar_bone_price = dec!(0.00000001); let pricer_decimals = 8; - let hnt_price = HntPrice::new(hnt_price_from_pricer, pricer_decimals); + let hnt_price = PriceInfo::new(hnt_price_from_pricer, pricer_decimals); - assert_eq!(hnt_dollar_bone_price, hnt_price.price_per_hnt_bone); - assert_eq!(hnt_price_from_pricer, hnt_price.hnt_price_in_bones); - assert_eq!(hnt_dollar_price, hnt_price.hnt_price); + assert_eq!(hnt_dollar_bone_price, hnt_price.price_per_bone); + assert_eq!(hnt_price_from_pricer, hnt_price.price_in_bones); + assert_eq!(hnt_dollar_price, hnt_price.price_per_token); } } diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index 892b27903..e983d00af 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -10,7 +10,7 @@ use crate::{ service_provider::{self, ServiceProviderDCSessions, ServiceProviderPromotions}, sp_boosted_rewards_bans, speedtests, speedtests_average::SpeedtestAverages, - subscriber_location, subscriber_verified_mapping_event, telemetry, HntPrice, Settings, + subscriber_location, subscriber_verified_mapping_event, telemetry, PriceInfo, Settings, MOBILE_SUB_DAO_ONCHAIN_ADDRESS, }; use anyhow::bail; @@ -41,8 +41,8 @@ use mobile_config::{ hex_boosting_client::HexBoostingInfoResolver, sub_dao_client::SubDaoEpochRewardInfoResolver, ClientError, }, - sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo, - EpochPeriod, + sub_dao_epoch_reward_info::EpochRewardInfo, + EpochInfo, }; use price::PriceTracker; use reward_scheduler::Scheduler; @@ -158,7 +158,7 @@ where loop { let next_reward_epoch = next_reward_epoch(&self.pool).await?; - let next_reward_epoch_period = EpochPeriod::from(next_reward_epoch); + let next_reward_epoch_period = EpochInfo::from(next_reward_epoch); let scheduler = Scheduler::new( self.reward_period_duration, @@ -270,14 +270,14 @@ where .price(&helium_proto::BlockchainTokenTypeV1::Hnt) .await?; - let hnt_price = HntPrice::new(pricer_hnt_price, Token::Hnt.decimals()); + let price_info = PriceInfo::new(pricer_hnt_price, Token::Hnt.decimals()); tracing::info!( - "Rewarding for epoch {} period: {} to {} with hnt bone price: {}", + "Rewarding for epoch {} period: {} to {} with bone price: {}", reward_info.epoch_day, reward_info.epoch_period.start, reward_info.epoch_period.end, - hnt_price.price_per_hnt_bone + price_info.price_per_bone ); // process rewards for poc and data transfer @@ -287,7 +287,7 @@ where &self.mobile_rewards, &self.speedtest_averages, &reward_info, - hnt_price.clone(), + price_info.clone(), ) .await?; @@ -309,7 +309,7 @@ where sp_promotions.clone(), &self.mobile_rewards, &reward_info, - hnt_price.price_per_hnt_bone, + price_info.price_per_bone, ) .await?; @@ -357,7 +357,7 @@ where written_files, reward_data: Some(MobileRewardData(reward_data)), epoch: reward_info.epoch_day, - price: hnt_price.hnt_price_in_bones, + price: price_info.price_in_bones, }, [], ) @@ -394,14 +394,14 @@ pub async fn reward_poc_and_dc( hex_service_client: &impl HexBoostingInfoResolver, mobile_rewards: &FileSinkClient, speedtest_avg_sink: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, - hnt_price: HntPrice, + reward_info: &EpochRewardInfo, + price_info: PriceInfo, ) -> anyhow::Result { let mut reward_shares = DataTransferAndPocAllocatedRewardBuckets::new(reward_info.epoch_emissions); let transfer_rewards = TransferRewards::from_transfer_sessions( - hnt_price, + price_info, data_session::aggregate_hotspot_data_sessions_to_dc(pool, &reward_info.epoch_period) .await?, &reward_shares, @@ -457,7 +457,7 @@ async fn reward_poc( hex_service_client: &impl HexBoostingInfoResolver, mobile_rewards: &FileSinkClient, speedtest_avg_sink: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, reward_shares: DataTransferAndPocAllocatedRewardBuckets, ) -> anyhow::Result<(Decimal, CalculatedPocRewardShares)> { let heartbeats = HeartbeatReward::validated(pool, &reward_info.epoch_period); @@ -533,7 +533,7 @@ async fn reward_poc( pub async fn reward_dc( mobile_rewards: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, transfer_rewards: TransferRewards, reward_shares: &DataTransferAndPocAllocatedRewardBuckets, ) -> anyhow::Result { @@ -558,7 +558,7 @@ pub async fn reward_dc( pub async fn reward_mappers( pool: &Pool, mobile_rewards: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, ) -> anyhow::Result<()> { // Mapper rewards currently include rewards for discovery mapping only. // Verification mapping rewards to be added @@ -616,7 +616,7 @@ pub async fn reward_mappers( pub async fn reward_oracles( mobile_rewards: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, ) -> anyhow::Result<()> { // atm 100% of oracle rewards are assigned to 'unallocated' let total_oracle_rewards = @@ -641,7 +641,7 @@ pub async fn reward_service_providers( dc_sessions: ServiceProviderDCSessions, sp_promotions: ServiceProviderPromotions, mobile_rewards: &FileSinkClient, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, hnt_bone_price: Decimal, ) -> anyhow::Result<()> { use service_provider::ServiceProviderRewardInfos; @@ -681,7 +681,7 @@ async fn write_unallocated_reward( mobile_rewards: &FileSinkClient, unallocated_type: UnallocatedRewardType, unallocated_amount: u64, - reward_info: &'_ ResolvedSubDaoEpochRewardInfo, + reward_info: &'_ EpochRewardInfo, ) -> anyhow::Result<()> { if unallocated_amount > 0 { let unallocated_reward = proto::MobileRewardShare { diff --git a/mobile_verifier/src/service_provider/reward.rs b/mobile_verifier/src/service_provider/reward.rs index f38015751..1e41ce44e 100644 --- a/mobile_verifier/src/service_provider/reward.rs +++ b/mobile_verifier/src/service_provider/reward.rs @@ -1,6 +1,6 @@ use crate::reward_shares::dc_to_hnt_bones; use file_store::traits::TimestampEncode; -use mobile_config::sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo; +use mobile_config::sub_dao_epoch_reward_info::EpochRewardInfo; use rust_decimal::{Decimal, RoundingStrategy}; use rust_decimal_macros::dec; @@ -20,7 +20,7 @@ mod proto { pub struct ServiceProviderRewardInfos { coll: Vec, total_sp_allocation: Decimal, - reward_info: ResolvedSubDaoEpochRewardInfo, + reward_info: EpochRewardInfo, } // Represents a single Service Providers information for rewarding, @@ -54,7 +54,7 @@ impl ServiceProviderRewardInfos { promotions: ServiceProviderPromotions, total_sp_allocation: Decimal, // Bones hnt_bone_price: Decimal, // Price in Bones - reward_info: ResolvedSubDaoEpochRewardInfo, + reward_info: EpochRewardInfo, ) -> Self { let all_transfer = dc_sessions.all_transfer(); // DC @@ -136,7 +136,7 @@ impl RewardInfo { pub fn iter_rewards( &self, total_allocation: Decimal, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, ) -> Vec<(u64, proto::MobileRewardShare)> { let mut rewards = self.promo_rewards(total_allocation, reward_info); rewards.push(self.carrier_reward(total_allocation, reward_info)); @@ -146,7 +146,7 @@ impl RewardInfo { pub fn carrier_reward( &self, total_allocation: Decimal, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, ) -> (u64, proto::MobileRewardShare) { let amount = (total_allocation * self.realized_data_perc).to_u64_floored(); // Rewarded BONES @@ -168,7 +168,7 @@ impl RewardInfo { pub fn promo_rewards( &self, total_allocation: Decimal, - reward_info: &ResolvedSubDaoEpochRewardInfo, + reward_info: &EpochRewardInfo, ) -> Vec<(u64, proto::MobileRewardShare)> { if self.promotions.is_empty() { return vec![]; @@ -278,12 +278,9 @@ mod tests { pub const EPOCH_ADDRESS: &str = "112E7TxoNHV46M6tiPA8N1MkeMeQxc9ztb4JQLXBVAAUfq1kJLoF"; pub const SUB_DAO_ADDRESS: &str = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6"; - pub fn default_rewards_info( - total_emissions: u64, - epoch_duration: Duration, - ) -> ResolvedSubDaoEpochRewardInfo { + pub fn default_rewards_info(total_emissions: u64, epoch_duration: Duration) -> EpochRewardInfo { let now = Utc::now(); - ResolvedSubDaoEpochRewardInfo { + EpochRewardInfo { epoch_day: 1, epoch_address: EPOCH_ADDRESS.into(), sub_dao_address: SUB_DAO_ADDRESS.into(), diff --git a/mobile_verifier/src/telemetry.rs b/mobile_verifier/src/telemetry.rs index 9c3e209d9..90ab7fc6c 100644 --- a/mobile_verifier/src/telemetry.rs +++ b/mobile_verifier/src/telemetry.rs @@ -1,6 +1,6 @@ use crate::rewarder; use chrono::{DateTime, Utc}; -use mobile_config::EpochPeriod; +use mobile_config::EpochInfo; use sqlx::{Pool, Postgres}; const LAST_REWARDED_END_TIME: &str = "last_rewarded_end_time"; @@ -8,7 +8,7 @@ const DATA_TRANSFER_REWARDS_SCALE: &str = "data_transfer_rewards_scale"; pub async fn initialize(db: &Pool) -> anyhow::Result<()> { let next_reward_epoch = rewarder::next_reward_epoch(db).await?; - let epoch_period: EpochPeriod = next_reward_epoch.into(); + let epoch_period: EpochInfo = next_reward_epoch.into(); last_rewarded_end_time(epoch_period.period.start); Ok(()) } diff --git a/mobile_verifier/tests/integrations/common/mod.rs b/mobile_verifier/tests/integrations/common/mod.rs index 669e1cb4e..64653b6ba 100644 --- a/mobile_verifier/tests/integrations/common/mod.rs +++ b/mobile_verifier/tests/integrations/common/mod.rs @@ -24,7 +24,7 @@ use mobile_config::{ }; use mobile_config::client::sub_dao_client::SubDaoEpochRewardInfoResolver; -use mobile_config::sub_dao_epoch_reward_info::ResolvedSubDaoEpochRewardInfo; +use mobile_config::sub_dao_epoch_reward_info::EpochRewardInfo; use mobile_verifier::{ boosting_oracles::AssignedCoverageObjects, GatewayResolution, GatewayResolver, }; @@ -46,7 +46,7 @@ pub struct MockHexBoostingClient { #[derive(Debug, Clone)] pub struct MockSubDaoRewardsClient { - info: Option, + info: Option, } impl MockHexBoostingClient { @@ -79,7 +79,7 @@ impl SubDaoEpochRewardInfoResolver for MockSubDaoRewardsClient { &self, _sub_dao: &str, _epoch: u64, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { Ok(self.info.clone()) } } @@ -386,12 +386,9 @@ impl GatewayResolver for GatewayClientAllOwnersValid { } } -pub fn default_rewards_info( - total_emissions: u64, - epoch_duration: Duration, -) -> ResolvedSubDaoEpochRewardInfo { +pub fn default_rewards_info(total_emissions: u64, epoch_duration: Duration) -> EpochRewardInfo { let now = Utc::now(); - ResolvedSubDaoEpochRewardInfo { + EpochRewardInfo { epoch_day: 1, epoch_address: EPOCH_ADDRESS.into(), sub_dao_address: SUB_DAO_ADDRESS.into(), diff --git a/mobile_verifier/tests/integrations/hex_boosting.rs b/mobile_verifier/tests/integrations/hex_boosting.rs index 133c5375d..26d9348cd 100644 --- a/mobile_verifier/tests/integrations/hex_boosting.rs +++ b/mobile_verifier/tests/integrations/hex_boosting.rs @@ -21,7 +21,7 @@ use mobile_verifier::{ cell_type::CellType, coverage::CoverageObject, heartbeats::{HbType, Heartbeat, ValidatedHeartbeat}, - radio_threshold, reward_shares, rewarder, speedtests, HntPrice, + radio_threshold, reward_shares, rewarder, speedtests, PriceInfo, }; use rust_decimal::prelude::*; use rust_decimal_macros::dec; @@ -141,9 +141,9 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { .unwrap(); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -153,7 +153,7 @@ async fn test_poc_with_boosted_hexes(pool: PgPool) -> anyhow::Result<()> { &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards_maybe_unallocated( &mut mobile_rewards, @@ -332,9 +332,9 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu let reward_info = default_rewards_info(82_191_780_821_917, Duration::hours(24)); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -344,7 +344,7 @@ async fn test_poc_boosted_hexes_thresholds_not_met(pool: PgPool) -> anyhow::Resu &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards(&mut mobile_rewards) ); @@ -499,9 +499,9 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res let hex_boosting_client = MockHexBoostingClient::new(boosted_hexes); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -511,7 +511,7 @@ async fn test_poc_with_multi_coverage_boosted_hexes(pool: PgPool) -> anyhow::Res &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards_maybe_unallocated( &mut mobile_rewards, @@ -678,9 +678,9 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { let hex_boosting_client = MockHexBoostingClient::new(boosted_hexes); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -690,7 +690,7 @@ async fn test_expired_boosted_hex(pool: PgPool) -> anyhow::Result<()> { &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards(&mut mobile_rewards) ); @@ -814,9 +814,9 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: .unwrap(); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -826,7 +826,7 @@ async fn test_reduced_location_score_with_boosted_hexes(pool: PgPool) -> anyhow: &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards_maybe_unallocated( &mut mobile_rewards, @@ -998,9 +998,9 @@ async fn test_distance_from_asserted_removes_boosting_but_not_location_trust( .unwrap(); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -1010,7 +1010,7 @@ async fn test_distance_from_asserted_removes_boosting_but_not_location_trust( &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards_maybe_unallocated( &mut mobile_rewards, @@ -1207,9 +1207,9 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an .unwrap(); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -1219,7 +1219,7 @@ async fn test_poc_with_cbrs_and_multi_coverage_boosted_hexes(pool: PgPool) -> an &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards_maybe_unallocated( &mut mobile_rewards, diff --git a/mobile_verifier/tests/integrations/rewarder_poc_dc.rs b/mobile_verifier/tests/integrations/rewarder_poc_dc.rs index 032944a39..ba5f2c56c 100644 --- a/mobile_verifier/tests/integrations/rewarder_poc_dc.rs +++ b/mobile_verifier/tests/integrations/rewarder_poc_dc.rs @@ -16,7 +16,7 @@ use mobile_verifier::{ coverage::CoverageObject, data_session, heartbeats::{HbType, Heartbeat, ValidatedHeartbeat}, - reward_shares, rewarder, speedtests, HntPrice, + reward_shares, rewarder, speedtests, PriceInfo, }; use rust_decimal::prelude::*; use rust_decimal_macros::dec; @@ -48,9 +48,9 @@ async fn test_poc_and_dc_rewards(pool: PgPool) -> anyhow::Result<()> { let hex_boosting_client = MockHexBoostingClient::new(boosted_hexes); // todo: rebalance the tests to use a normalised hnt price - let hnt_price = HntPrice::new(10000000000000000, 8); - assert_eq!(hnt_price.hnt_price, dec!(100000000)); - assert_eq!(hnt_price.price_per_hnt_bone, dec!(1)); + let price_info = PriceInfo::new(10000000000000000, 8); + assert_eq!(price_info.price_per_token, dec!(100000000)); + assert_eq!(price_info.price_per_bone, dec!(1)); let (_, rewards) = tokio::join!( // run rewards for poc and dc @@ -60,7 +60,7 @@ async fn test_poc_and_dc_rewards(pool: PgPool) -> anyhow::Result<()> { &mobile_rewards_client, &speedtest_avg_client, &reward_info, - hnt_price + price_info ), receive_expected_rewards(&mut mobile_rewards) );