Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions file_store/src/usage_counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use chrono::{DateTime, Utc};
use h3o::CellIndex;
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::{
HexUsageStatsIngestReportV1, HexUsageStatsReqV1, RadioUsageStatsIngestReportV1,
RadioUsageStatsReqV1,
HexUsageStatsIngestReportV1, HexUsageStatsReqV1, RadioUsageCarrierTransferInfo,
RadioUsageStatsIngestReportV1, RadioUsageStatsReqV1,
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -40,6 +40,7 @@ pub struct RadioUsageStatsReq {
pub epoch_end_timestamp: DateTime<Utc>,
pub timestamp: DateTime<Utc>,
pub carrier_mapping_key: PublicKeyBinary,
pub carrier_transfer_info: Vec<RadioUsageCarrierTransferInfo>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in the from function.
The from functions itself is used in the next from (RadioUsageCountsIngestReport to RadioUsageStatsIngestReportV1), this (next) from is not used across oracles repository, but it could be used in the another projects that use file-store as dependency.
So I've added this to ensure feature completeness.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of anywhere this from conversion is used, wasn't sure if you did

}

impl MsgDecode for HexUsageStatsReq {
Expand Down Expand Up @@ -137,6 +138,7 @@ impl TryFrom<RadioUsageStatsReqV1> for RadioUsageStatsReq {
epoch_end_timestamp,
timestamp,
carrier_mapping_key: v.carrier_mapping_key.into(),
carrier_transfer_info: v.carrier_transfer_info,
})
}
}
Expand All @@ -159,6 +161,7 @@ impl From<RadioUsageStatsReq> for RadioUsageStatsReqV1 {
epoch_end_timestamp,
timestamp,
carrier_mapping_key: v.carrier_mapping_key.into(),
carrier_transfer_info: v.carrier_transfer_info,
signature: vec![],
}
}
Expand Down
4 changes: 2 additions & 2 deletions ingest/src/server_mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ where
let (verified_pubkey, event) = self
.verify_public_key(event.carrier_mapping_key.as_ref())
.and_then(|public_key| self.verify_network(public_key))
.and_then(|public_key| self.verify_signature(public_key, event.clone()))?;
.and_then(|public_key| self.verify_signature(public_key, event))?;
self.verify_known_carrier_key(verified_pubkey).await?;

let report = HexUsageStatsIngestReportV1 {
Expand All @@ -550,7 +550,7 @@ where
let (verified_pubkey, event) = self
.verify_public_key(event.carrier_mapping_key.as_ref())
.and_then(|public_key| self.verify_network(public_key))
.and_then(|public_key| self.verify_signature(public_key, event.clone()))?;
.and_then(|public_key| self.verify_signature(public_key, event))?;
self.verify_known_carrier_key(verified_pubkey).await?;

let report = RadioUsageStatsIngestReportV1 {
Expand Down
9 changes: 6 additions & 3 deletions ingest/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use helium_proto::services::poc_mobile::{
BanIngestReportV1, BanReqV1, BanRespV1, CellHeartbeatReqV1, CellHeartbeatRespV1,
DataTransferEvent, DataTransferRadioAccessTechnology, DataTransferSessionIngestReportV1,
DataTransferSessionReqV1, DataTransferSessionRespV1, HexUsageStatsIngestReportV1,
HexUsageStatsReqV1, HexUsageStatsResV1, RadioUsageStatsIngestReportV1, RadioUsageStatsReqV1,
RadioUsageStatsResV1, UniqueConnectionsIngestReportV1, UniqueConnectionsReqV1,
UniqueConnectionsRespV1,
HexUsageStatsReqV1, HexUsageStatsResV1, RadioUsageCarrierTransferInfo,
RadioUsageStatsIngestReportV1, RadioUsageStatsReqV1, RadioUsageStatsResV1,
UniqueConnectionsIngestReportV1, UniqueConnectionsReqV1, UniqueConnectionsRespV1,
};
use helium_proto::services::{
mobile_config::NetworkKeyRole,
Expand Down Expand Up @@ -401,6 +401,7 @@ impl TestClient {
Ok(res.into_inner())
}

#[allow(clippy::too_many_arguments)]
pub async fn submit_radio_usage_req(
&mut self,
hotspot_pubkey: PublicKeyBinary,
Expand All @@ -409,6 +410,7 @@ impl TestClient {
offload_user_count: u64,
service_provider_transfer_bytes: u64,
offload_transfer_bytes: u64,
carrier_transfer_info: Vec<RadioUsageCarrierTransferInfo>,
) -> anyhow::Result<RadioUsageStatsResV1> {
let mut req = RadioUsageStatsReqV1 {
hotspot_pubkey: hotspot_pubkey.into(),
Expand All @@ -421,6 +423,7 @@ impl TestClient {
epoch_start_timestamp: 0,
epoch_end_timestamp: 0,
timestamp: 0,
carrier_transfer_info,
carrier_mapping_key: self.key_pair.public_key().to_vec(),
signature: vec![],
};
Expand Down
12 changes: 11 additions & 1 deletion ingest/tests/mobile_ingest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use chrono::{TimeZone, Utc};
use common::generate_keypair;
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::DataTransferRadioAccessTechnology;
use helium_proto::services::poc_mobile::{
DataTransferRadioAccessTechnology, RadioUsageCarrierTransferInfo,
};
use std::str::FromStr;

mod common;
Expand Down Expand Up @@ -153,6 +155,11 @@ async fn submit_radio_usage_report() -> anyhow::Result<()> {
const OFFLOAD_USER_COUNT: u64 = 12;
const SERVICE_PROVIDER_TRANSFER_BYTES: u64 = 13;
const OFFLOAD_TRANSFER_BYTES: u64 = 14;
let radio_usage_carrier_info = RadioUsageCarrierTransferInfo {
carrier_id: 1,
transfer_bytes: OFFLOAD_TRANSFER_BYTES,
user_count: 2,
};

let res = client
.submit_radio_usage_req(
Expand All @@ -162,6 +169,7 @@ async fn submit_radio_usage_report() -> anyhow::Result<()> {
OFFLOAD_USER_COUNT,
SERVICE_PROVIDER_TRANSFER_BYTES,
OFFLOAD_TRANSFER_BYTES,
vec![radio_usage_carrier_info.clone()],
)
.await;

Expand All @@ -188,6 +196,8 @@ async fn submit_radio_usage_report() -> anyhow::Result<()> {
event.service_provider_transfer_bytes
);
assert_eq!(OFFLOAD_TRANSFER_BYTES, event.offload_transfer_bytes);
assert_eq!(OFFLOAD_TRANSFER_BYTES, event.offload_transfer_bytes);
assert_eq!(vec![radio_usage_carrier_info], event.carrier_transfer_info);
}
}
}
Expand Down
Loading