Skip to content

Commit

Permalink
Clippy and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maplant committed May 6, 2024
1 parent ffe553e commit f95aef9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mobile_verifier/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl CoverageDaemon {
self.coverage_obj_sink.commit().await?;
transaction.commit().await?;

// Tell the data set manager to update the assignments.
// Tell the data set manager to update the assignments.
self.new_coverage_object_signal.try_send(())?;

Ok(())
Expand Down
1 change: 0 additions & 1 deletion mobile_verifier/tests/integrations/boosting_oracles.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::common;
use anyhow::Context;
use chrono::{DateTime, Duration, Utc};
use file_store::{
Expand Down
36 changes: 19 additions & 17 deletions mobile_verifier/tests/integrations/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use mobile_config::{
boosted_hex_info::{BoostedHexInfo, BoostedHexInfoStream},
client::{hex_boosting_client::HexBoostingInfoResolver, ClientError},
};
use mobile_verifier::boosting_oracles::{Assignment, BoostedHexAssignments, HexAssignments};
use mobile_verifier::boosting_oracles::{Assignment, HexBoostData};
use std::collections::HashMap;
use tokio::{sync::mpsc::error::TryRecvError, time::timeout};

Expand Down Expand Up @@ -182,24 +182,26 @@ pub fn seconds(s: u64) -> std::time::Duration {

type MockAssignmentMap = HashMap<hextree::Cell, Assignment>;

#[derive(Default)]
pub fn mock_hex_boost_data_default(
) -> HexBoostData<MockAssignmentMap, MockAssignmentMap, MockAssignmentMap> {
HexBoostData::builder()
.urbanization(MockAssignmentMap::default())
.footfall(MockAssignmentMap::default())
.landtype(MockAssignmentMap::default())
.build()
.unwrap()
}

#[allow(dead_code)]
pub struct MockHexAssignments {
pub fn mock_hex_boost_data(
footfall: MockAssignmentMap,
urbanized: MockAssignmentMap,
landtype: MockAssignmentMap,
}

impl MockHexAssignments {
pub fn new(
footfall: MockAssignmentMap,
urbanized: MockAssignmentMap,
landtype: MockAssignmentMap,
) -> Self {
Self {
footfall,
urbanized,
landtype,
}
}
) -> HexBoostData<MockAssignmentMap, MockAssignmentMap, MockAssignmentMap> {
HexBoostData::builder()
.footfall(footfall)
.urbanization(urbanized)
.landtype(landtype)
.build()
.unwrap()
}
8 changes: 6 additions & 2 deletions mobile_verifier/tests/integrations/hex_boosting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ const BOOST_CONFIG_PUBKEY: &str = "BZM1QTud72B2cpTW7PhEnFmRX7ZWzvY7DpPpNJJuDrWG"

async fn update_assignments(pool: &PgPool) -> anyhow::Result<()> {
let unassigned_hexes = UnassignedHex::fetch_unassigned(pool);
let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool)
.await?;
let _ = set_oracle_boosting_assignments(
unassigned_hexes,
&common::mock_hex_boost_data_default(),
pool,
)
.await?;
Ok(())
}

Expand Down
9 changes: 6 additions & 3 deletions mobile_verifier/tests/integrations/modeled_coverage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::common;
use chrono::{DateTime, Duration, Utc};
use common::MockHexAssignments;
use file_store::{
coverage::{CoverageObjectIngestReport, RadioHexSignalLevel},
heartbeat::{CbrsHeartbeat, CbrsHeartbeatIngestReport},
Expand Down Expand Up @@ -407,8 +406,12 @@ async fn process_input(
transaction.commit().await?;

let unassigned_hexes = UnassignedHex::fetch_unassigned(pool);
let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool)
.await?;
let _ = set_oracle_boosting_assignments(
unassigned_hexes,
&common::mock_hex_boost_data_default(),
pool,
)
.await?;

let mut transaction = pool.begin().await?;
let mut heartbeats = pin!(ValidatedHeartbeat::validate_heartbeats(
Expand Down
9 changes: 6 additions & 3 deletions mobile_verifier/tests/integrations/rewarder_poc_dc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::common::{self, MockFileSinkReceiver, MockHexBoostingClient};
use chrono::{DateTime, Duration as ChronoDuration, Utc};
use common::MockHexAssignments;
use file_store::{
coverage::{CoverageObject as FSCoverageObject, KeyType, RadioHexSignalLevel},
speedtest::CellSpeedtest,
Expand Down Expand Up @@ -268,8 +267,12 @@ async fn seed_heartbeats(

async fn update_assignments(pool: &PgPool) -> anyhow::Result<()> {
let unassigned_hexes = UnassignedHex::fetch_unassigned(pool);
let _ = set_oracle_boosting_assignments(unassigned_hexes, &MockHexAssignments::best(), pool)
.await?;
let _ = set_oracle_boosting_assignments(
unassigned_hexes,
&common::mock_hex_boost_data_default(),
pool,
)
.await?;
Ok(())
}

Expand Down

0 comments on commit f95aef9

Please sign in to comment.