Skip to content

Commit

Permalink
add integration tests for reward entities, refactor to accomodate
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Jan 10, 2024
1 parent ca8715d commit cd4c646
Show file tree
Hide file tree
Showing 15 changed files with 1,208 additions and 246 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions file_store/src/file_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ impl FileSinkBuilder {

#[derive(Debug, Clone)]
pub struct FileSinkClient {
sender: MessageSender,
metric: &'static str,
pub sender: MessageSender,
pub metric: &'static str,
}

const OK_LABEL: Label = Label::from_static_parts("status", "ok");
Expand Down
3 changes: 3 additions & 0 deletions mobile_config/src/client/carrier_service_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl CarrierServiceVerifier for CarrierServiceClient {
response.verify(&self.config_pubkey)?;
response.entity_key
}
Err(status) if status.code() == tonic::Code::NotFound => {
Err(ClientError::UnknownServiceProvider)?
}
Err(status) => Err(status)?,
};
self.cache
Expand Down
2 changes: 1 addition & 1 deletion mobile_config/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum ClientError {
VerificationError(#[from] file_store::Error),
#[error("error parsing gateway location {0}")]
LocationParseError(#[from] std::num::ParseIntError),
#[error("unknown service provider")]
#[error("unknown service provider name")]
UnknownServiceProvider,
}

Expand Down
4 changes: 4 additions & 0 deletions mobile_verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ humantime = {workspace = true}
rust_decimal = {workspace = true}
rust_decimal_macros = {workspace = true}
tonic = {workspace = true}
tokio-stream = { workspace = true }
metrics = {workspace = true}
metrics-exporter-prometheus = {workspace = true}
mobile-config = {path = "../mobile_config"}
Expand All @@ -46,3 +47,6 @@ rand = {workspace = true}
async-trait = {workspace = true}
retainer = {workspace = true}
uuid = {workspace = true}

[dev-dependencies]
backon = "0"
1 change: 1 addition & 0 deletions mobile_verifier/src/data_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl HotspotDataSession {
.await?;
Ok(())
}

fn from_valid_data_session(
v: ValidDataTransferSession,
received_timestamp: DateTime<Utc>,
Expand Down
6 changes: 3 additions & 3 deletions mobile_verifier/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pub mod cell_type;
pub mod cli;
pub mod coverage;
mod data_session;
pub mod data_session;
pub mod heartbeats;
pub mod reward_shares;
pub mod rewarder;
mod settings;
pub mod speedtests;
pub mod speedtests_average;
mod subscriber_location;
mod telemetry;
pub mod subscriber_location;
pub mod telemetry;

pub use settings::Settings;

Expand Down
12 changes: 7 additions & 5 deletions mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use chrono::{DateTime, Duration, Utc};
use file_store::traits::TimestampEncode;
use futures::{Stream, StreamExt};
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::{
ServiceProvider, UnallocatedReward, UnallocatedRewardType,
};
use helium_proto::services::{
poc_mobile as proto, poc_mobile::mobile_reward_share::Reward as ProtoReward,
poc_mobile as proto,
poc_mobile::{
mobile_reward_share::Reward as ProtoReward, ServiceProvider, UnallocatedReward,
UnallocatedRewardType,
},
};
use mobile_config::client::{carrier_service_client::CarrierServiceVerifier, ClientError};
use rust_decimal::prelude::*;
Expand Down Expand Up @@ -47,6 +48,7 @@ const SERVICE_PROVIDER_PERCENT: Decimal = dec!(0.1);
// Percent of total emissions allocated for oracles
const ORACLES_PERCENT: Decimal = dec!(0.04);

#[derive(Debug)]
pub struct TransferRewards {
reward_scale: Decimal,
rewards: HashMap<PublicKeyBinary, Decimal>,
Expand Down Expand Up @@ -336,7 +338,7 @@ impl ServiceProviderShares {
fn entity_key_to_service_provider(key: &str) -> anyhow::Result<ServiceProvider> {
match key {
"Helium Mobile" => Ok(ServiceProvider::HeliumMobile),
_ => bail!("invalid service provider name"),
_ => bail!("unknown service provider name"),
}
}
}
Expand Down
Loading

0 comments on commit cd4c646

Please sign in to comment.