Artificially advance time on BridgeDb

This commit is contained in:
Vecna 2024-06-06 16:37:16 -04:00
parent 766516cee3
commit 13d098eaa0
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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 {