From 13d098eaa0ebf1eb66bb09ddd0346b312fca0f51 Mon Sep 17 00:00:00 2001 From: Vecna Date: Thu, 6 Jun 2024 16:37:16 -0400 Subject: [PATCH] Artificially advance time on BridgeDb --- crates/lox-distributor/src/lox_context.rs | 3 +++ crates/lox-library/src/lib.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/crates/lox-distributor/src/lox_context.rs b/crates/lox-distributor/src/lox_context.rs index d7bdb13..0f256d0 100644 --- a/crates/lox-distributor/src/lox_context.rs +++ b/crates/lox-distributor/src/lox_context.rs @@ -415,6 +415,9 @@ impl LoxServerContext { let mut ba_obj = self.ba.lock().unwrap(); ba_obj.advance_days(num); // FOR TESTING ONLY println!("Today's date according to server: {}", ba_obj.today()); + // Also advance days for BridgeDb + let mut db_obj = self.db.lock().unwrap(); + db_obj.advance_days(num); // FOR TESTING ONLY } // Encrypts the Lox bridge table, should be called after every sync diff --git a/crates/lox-library/src/lib.rs b/crates/lox-library/src/lib.rs index 3ade055..8ed51bf 100644 --- a/crates/lox-library/src/lib.rs +++ b/crates/lox-library/src/lib.rs @@ -287,6 +287,17 @@ impl BridgeDb { Err(SignatureError::new()) } } + + ///#[cfg(test)] + /// For testing only: manually advance the day by the given number + /// of days + pub fn advance_days(&mut self, days: u16) { + if days > 0 { + self.today += Duration::days(days.into()); + // Reset daily bridges distributed count + self.daily_bridges_distributed = 0; + } + } } impl Default for BridgeDb {