Skip to content

tor-rtmock: task: Provide advance_* to replace advance

Ian Jackson requested to merge Diziet/arti:mock-advance into main

These new functions do the "advance time in steps" loop for you.

FYI, I experimentally merged this with gabi-250/arti@d1f2e45e from https://gitlab.torproject.org/gabi-250/arti/-/commits/backoff-bad and the patch below (to use the new function in the non-working test there) and it still failed with "all futures blocked. waiting for the real world? or deadlocked (waiting for each other) ?"

Looking at the backtraces, there are now three tasks. One is the main task, sleeping in advance, as expected, slthough, it previously slept on oneshot::Receiver, and hasn't woken up since. Which is a bit odd. The other is "retry runner task: backoff with timeout and no max_retries (transient errors)", which, apparently, it asleep, but hasn't cloned the Waker. I think that means it can never wake up.

DYK what is happening here?

diff --git a/crates/tor-rtmock/src/runtime.rs b/crates/tor-rtmock/src/runtime.rs
index 0c397d4d2..8683b2014 100644
--- a/crates/tor-rtmock/src/runtime.rs
+++ b/crates/tor-rtmock/src/runtime.rs
@@ -308,7 +308,7 @@ impl MockRuntime {
     /// use `runtime.mock_sleep().advance()`.
     #[deprecated(note = "use MockRuntime::advance_by, or MockSleepProvider::advance()")]
     pub async fn advance(&self, dur: Duration) {
-        self.sleep.advance(dur).await;
+        self.advance_by(dur).await;
     }
 }
 

(The branch here is on top of !1591 (merged))

Merge request reports