Skip to content

Commit

Permalink
Fix inserted_at for seniority to Utc::now() (#890)
Browse files Browse the repository at this point in the history
* Fix inserted_at for seniority  to Utc::now()

* Fix tests
  • Loading branch information
macpie authored Nov 7, 2024
1 parent dad56fb commit 6c67e36
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion mobile_verifier/src/seniority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl SeniorityUpdate<'_> {
.bind(self.heartbeat_ts)
.bind(self.uuid)
.bind(new_seniority)
.bind(self.heartbeat_ts)
.bind(Utc::now())
.bind(update_reason as i32)
.bind(self.key.hb_type())
.execute(&mut *exec)
Expand Down
12 changes: 5 additions & 7 deletions mobile_verifier/tests/integrations/boosting_oracles.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::common::{self, GatewayClientAllOwnersValid};
use anyhow::Context;
use chrono::{DateTime, Duration, Utc};
use file_store::{
Expand All @@ -13,7 +14,6 @@ use helium_proto::services::poc_mobile::{
};
use hex_assignments::{Assignment, HexBoostData};
use mobile_config::boosted_hex_info::BoostedHexes;

use mobile_verifier::{
coverage::{CoverageClaimTimeCache, CoverageObject, CoverageObjectCache},
geofence::GeofenceValidator,
Expand All @@ -31,8 +31,6 @@ use sqlx::PgPool;
use std::{collections::HashMap, pin::pin};
use uuid::Uuid;

use crate::common::{self, GatewayClientAllOwnersValid};

#[derive(Clone)]
struct MockGeofence;

Expand Down Expand Up @@ -213,8 +211,8 @@ async fn test_footfall_and_urbanization_report(pool: PgPool) -> anyhow::Result<(

#[sqlx::test]
async fn test_footfall_and_urbanization_and_landtype(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-01-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-01-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

struct TestHex {
loc: String,
Expand Down Expand Up @@ -307,7 +305,7 @@ async fn test_footfall_and_urbanization_and_landtype(pool: PgPool) -> anyhow::Re
pub_key: PublicKeyBinary::from(vec![1]),
uuid,
key_type: file_store::coverage::KeyType::CbsdId(cbsd_id.clone()),
coverage_claim_time: "2022-01-01 00:00:00.000000000 UTC".parse()?,
coverage_claim_time: start,
indoor: true,
signature: Vec::new(),
coverage: hexes
Expand All @@ -334,7 +332,7 @@ async fn test_footfall_and_urbanization_and_landtype(pool: PgPool) -> anyhow::Re
let _ = common::set_unassigned_oracle_boosting_assignments(&pool, &hex_boost_data).await?;

let heartbeat_owner = owner.clone();
let heartbeats = heartbeats(12, start, &heartbeat_owner, &cbsd_id, 0.0, 0.0, uuid);
let heartbeats = heartbeats(13, start, &heartbeat_owner, &cbsd_id, 0.0, 0.0, uuid);

let coverage_objects = CoverageObjectCache::new(&pool);
let coverage_claim_time_cache = CoverageClaimTimeCache::new();
Expand Down
60 changes: 30 additions & 30 deletions mobile_verifier/tests/integrations/modeled_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ async fn process_input(

#[sqlx::test]
async fn scenario_one(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-01-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-01-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

let uuid = Uuid::new_v4();
let cbsd_id = "P27-SCE4255W120200039521XGB0102".to_string();
Expand Down Expand Up @@ -462,7 +462,7 @@ async fn scenario_one(pool: PgPool) -> anyhow::Result<()> {
&pool,
&(start..end),
vec![coverage_object].into_iter(),
heartbeats(12, start, &owner, &cbsd_id, 0.0, 0.0, uuid),
heartbeats(13, start, &owner, &cbsd_id, 0.0, 0.0, uuid),
)
.await?;

Expand Down Expand Up @@ -498,8 +498,8 @@ async fn scenario_one(pool: PgPool) -> anyhow::Result<()> {

#[sqlx::test]
async fn scenario_two(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-02-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-02-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

let uuid_1 = Uuid::new_v4();
let uuid_2 = Uuid::new_v4();
Expand Down Expand Up @@ -553,8 +553,8 @@ async fn scenario_two(pool: PgPool) -> anyhow::Result<()> {
let owner_1: PublicKeyBinary = "11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9".parse()?;
let owner_2: PublicKeyBinary = "11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR".parse()?;

let heartbeats_1 = heartbeats(12, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(12, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_1 = heartbeats(13, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(13, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);

process_input(
&pool,
Expand Down Expand Up @@ -605,8 +605,8 @@ async fn scenario_two(pool: PgPool) -> anyhow::Result<()> {

#[sqlx::test]
async fn scenario_three(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-02-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-02-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

let uuid_1 = Uuid::new_v4();
let uuid_2 = Uuid::new_v4();
Expand Down Expand Up @@ -763,12 +763,12 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> {
let owner_5: PublicKeyBinary = "11Bn2erjB83zdCBrE248pTVBpTXSuN8Lur4v4mWFnf5Rpd8XK7n".parse()?;
let owner_6: PublicKeyBinary = "11d5KySrfiMgaDoZ7B5CDm3meE1gQhUJ5EHuJvzwiWjdSUGhBsZ".parse()?;

let heartbeats_1 = heartbeats(12, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(12, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_3 = heartbeats(12, start, &owner_3, &cbsd_id_3, 0.0, 0.0, uuid_3);
let heartbeats_4 = heartbeats(12, start, &owner_4, &cbsd_id_4, 0.0, 0.0, uuid_4);
let heartbeats_5 = heartbeats(12, start, &owner_5, &cbsd_id_5, 0.0, 0.0, uuid_5);
let heartbeats_6 = heartbeats(12, start, &owner_6, &cbsd_id_6, 0.0, 0.0, uuid_6);
let heartbeats_1 = heartbeats(13, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(13, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_3 = heartbeats(13, start, &owner_3, &cbsd_id_3, 0.0, 0.0, uuid_3);
let heartbeats_4 = heartbeats(13, start, &owner_4, &cbsd_id_4, 0.0, 0.0, uuid_4);
let heartbeats_5 = heartbeats(13, start, &owner_5, &cbsd_id_5, 0.0, 0.0, uuid_5);
let heartbeats_6 = heartbeats(13, start, &owner_6, &cbsd_id_6, 0.0, 0.0, uuid_6);

process_input(
&pool,
Expand Down Expand Up @@ -910,8 +910,8 @@ async fn scenario_three(pool: PgPool) -> anyhow::Result<()> {

#[sqlx::test]
async fn scenario_four(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-01-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-01-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

let uuid = Uuid::new_v4();
let cbsd_id = "P27-SCE4255W120200039521XGB0102".to_string();
Expand Down Expand Up @@ -944,7 +944,7 @@ async fn scenario_four(pool: PgPool) -> anyhow::Result<()> {
&pool,
&(start..end),
vec![coverage_object].into_iter(),
heartbeats(12, start, &owner, &cbsd_id, 0.0, 0.0, uuid),
heartbeats(13, start, &owner, &cbsd_id, 0.0, 0.0, uuid),
)
.await?;

Expand Down Expand Up @@ -980,8 +980,8 @@ async fn scenario_four(pool: PgPool) -> anyhow::Result<()> {

#[sqlx::test]
async fn scenario_five(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-02-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-02-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

let uuid_1 = Uuid::new_v4();
let uuid_2 = Uuid::new_v4();
Expand Down Expand Up @@ -1034,8 +1034,8 @@ async fn scenario_five(pool: PgPool) -> anyhow::Result<()> {
let owner_1: PublicKeyBinary = "11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9".parse()?;
let owner_2: PublicKeyBinary = "11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR".parse()?;

let heartbeats_1 = heartbeats(12, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(12, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_1 = heartbeats(13, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(13, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);

process_input(
&pool,
Expand Down Expand Up @@ -1086,8 +1086,8 @@ async fn scenario_five(pool: PgPool) -> anyhow::Result<()> {

#[sqlx::test]
async fn scenario_six(pool: PgPool) -> anyhow::Result<()> {
let start: DateTime<Utc> = "2022-02-01 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = "2022-02-02 00:00:00.000000000 UTC".parse()?;
let end: DateTime<Utc> = Utc::now() + Duration::minutes(10);
let start: DateTime<Utc> = end - Duration::days(1);

// This is the same as scenario three, but with an acceptable speedtest
// the sixth radio is not awarded
Expand Down Expand Up @@ -1247,12 +1247,12 @@ async fn scenario_six(pool: PgPool) -> anyhow::Result<()> {
let owner_5: PublicKeyBinary = "11Bn2erjB83zdCBrE248pTVBpTXSuN8Lur4v4mWFnf5Rpd8XK7n".parse()?;
let owner_6: PublicKeyBinary = "11d5KySrfiMgaDoZ7B5CDm3meE1gQhUJ5EHuJvzwiWjdSUGhBsZ".parse()?;

let heartbeats_1 = heartbeats(12, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(12, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_3 = heartbeats(12, start, &owner_3, &cbsd_id_3, 0.0, 0.0, uuid_3);
let heartbeats_4 = heartbeats(12, start, &owner_4, &cbsd_id_4, 0.0, 0.0, uuid_4);
let heartbeats_5 = heartbeats(12, start, &owner_5, &cbsd_id_5, 0.0, 0.0, uuid_5);
let heartbeats_6 = heartbeats(12, start, &owner_6, &cbsd_id_6, 0.0, 0.0, uuid_6);
let heartbeats_1 = heartbeats(13, start, &owner_1, &cbsd_id_1, 0.0, 0.0, uuid_1);
let heartbeats_2 = heartbeats(13, start, &owner_2, &cbsd_id_2, 0.0, 0.0, uuid_2);
let heartbeats_3 = heartbeats(13, start, &owner_3, &cbsd_id_3, 0.0, 0.0, uuid_3);
let heartbeats_4 = heartbeats(13, start, &owner_4, &cbsd_id_4, 0.0, 0.0, uuid_4);
let heartbeats_5 = heartbeats(13, start, &owner_5, &cbsd_id_5, 0.0, 0.0, uuid_5);
let heartbeats_6 = heartbeats(13, start, &owner_6, &cbsd_id_6, 0.0, 0.0, uuid_6);

process_input(
&pool,
Expand Down

0 comments on commit 6c67e36

Please sign in to comment.