Test-case preemptive::test::does_not_predict_old_ports fails in AppVeyor
I added a bit of debug to get some context here:
diff --git a/crates/tor-circmgr/src/preemptive.rs b/crates/tor-circmgr/src/preemptive.rs
index b7c9c5ef..e16d36e9 100644
--- a/crates/tor-circmgr/src/preemptive.rs
+++ b/crates/tor-circmgr/src/preemptive.rs
@@ -167,7 +167,9 @@ fn does_not_predict_old_ports() {
cfg.set_initial_predicted_ports(vec![]);
cfg.prediction_lifetime(Duration::from_secs(2));
let mut predictor = PreemptiveCircuitPredictor::new(cfg.build().unwrap());
- let more_than_an_hour_ago = Instant::now() - Duration::from_secs(60 * 60 + 1);
+ let now = Instant::now();
+ dbg!(&now);
+ let more_than_an_hour_ago = now - Duration::from_secs(60 * 60 + 1);
predictor.note_usage(Some(TargetPort::ipv4(2345)), more_than_an_hour_ago);
The test fails with:
[crates\tor-circmgr\src\preemptive.rs:171] &now = Instant {
t: 1148.8979544s,
}
thread 'preemptive::test::does_not_predict_old_ports' panicked at 'overflow when subtracting duration from instant', library\std\src\time.rs:424:33
It seems like the VM/container that AppVeyor spawns is started right before our build, so when we get to run our tests the call to Instant::now()
yields 1148.8979544s
which is less than 3601 seconds we use in more_than_an_hour_ago
which leads to the overflow.
Edited by Alexander Hansen Færøy