Loading crates/tor-circmgr/src/build.rs +4 −0 Original line number Diff line number Diff line Loading @@ -448,6 +448,7 @@ mod test { } test_with_all_runtimes!(|rto| async move { #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that's ready immediately. Loading @@ -456,6 +457,7 @@ mod test { assert_eq!(x.unwrap(), 3_u32); eprintln!("acquiesce after test1"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that's ready after a short delay. Loading @@ -482,6 +484,7 @@ mod test { assert_eq!(x.unwrap(), 4_u32); eprintln!("acquiesce after test2"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that passes the first timeout, and make sure that Loading Loading @@ -511,6 +514,7 @@ mod test { assert_eq!(waited, Ok(())); eprintln!("acquiesce after test3"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that times out and gets abandoned. Loading crates/tor-netdoc/src/types/misc.rs +2 −3 Original line number Diff line number Diff line Loading @@ -264,9 +264,8 @@ mod edcert { impl super::FromBytes for UnvalidatedEdCert { fn from_bytes(b: &[u8], p: Pos) -> Result<Self> { let cert = Ed25519Cert::decode(b).map_err(|e| { Error::BadObjectVal(p, format!("Bad certificate: {}", e.to_string())) })?; let cert = Ed25519Cert::decode(b) .map_err(|e| Error::BadObjectVal(p, format!("Bad certificate: {}", e)))?; Ok(Self(cert, p)) } fn from_vec(v: Vec<u8>, p: Pos) -> Result<Self> { Loading crates/tor-rtmock/src/sleep_runtime.rs +4 −3 Original line number Diff line number Diff line Loading @@ -68,9 +68,10 @@ impl<R: Runtime> MockSleepRuntime<R> { /// Panics if another `WaitFor` future is already running. (If two ran simultaneously, they /// would both try and advance the same mock time clock, which would be bad.) pub fn wait_for<F: futures::Future>(&self, fut: F) -> WaitFor<F> { if self.sleep.has_waitfor_waker() { panic!("attempted to call MockSleepRuntime::wait_for while another WaitFor is active"); } assert!( !self.sleep.has_waitfor_waker(), "attempted to call MockSleepRuntime::wait_for while another WaitFor is active" ); WaitFor { sleep: self.sleep.clone(), fut, Loading crates/tor-rtmock/src/time.rs +8 −6 Original line number Diff line number Diff line Loading @@ -196,12 +196,14 @@ impl MockSleepProvider { .peek() .map(|sleepent| sleepent.when.saturating_duration_since(now)) }; if next_timeout.is_none() { let next_timeout = match next_timeout { Some(x) => x, None => { // There's no timeout set, so we really shouldn't be here anyway. eprintln!("should_advance = false; allow_one set but no timeout yet"); return false; } let next_timeout = next_timeout.unwrap(); }; if next_timeout <= state.allowed_advance { // We can advance up to the next timeout, since it's in our quota. // Subtract the amount we're going to advance by from said quota. Loading Loading
crates/tor-circmgr/src/build.rs +4 −0 Original line number Diff line number Diff line Loading @@ -448,6 +448,7 @@ mod test { } test_with_all_runtimes!(|rto| async move { #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that's ready immediately. Loading @@ -456,6 +457,7 @@ mod test { assert_eq!(x.unwrap(), 3_u32); eprintln!("acquiesce after test1"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that's ready after a short delay. Loading @@ -482,6 +484,7 @@ mod test { assert_eq!(x.unwrap(), 4_u32); eprintln!("acquiesce after test2"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that passes the first timeout, and make sure that Loading Loading @@ -511,6 +514,7 @@ mod test { assert_eq!(waited, Ok(())); eprintln!("acquiesce after test3"); #[allow(clippy::clone_on_copy)] let rt = tor_rtmock::MockSleepRuntime::new(rto.clone()); // Try a future that times out and gets abandoned. Loading
crates/tor-netdoc/src/types/misc.rs +2 −3 Original line number Diff line number Diff line Loading @@ -264,9 +264,8 @@ mod edcert { impl super::FromBytes for UnvalidatedEdCert { fn from_bytes(b: &[u8], p: Pos) -> Result<Self> { let cert = Ed25519Cert::decode(b).map_err(|e| { Error::BadObjectVal(p, format!("Bad certificate: {}", e.to_string())) })?; let cert = Ed25519Cert::decode(b) .map_err(|e| Error::BadObjectVal(p, format!("Bad certificate: {}", e)))?; Ok(Self(cert, p)) } fn from_vec(v: Vec<u8>, p: Pos) -> Result<Self> { Loading
crates/tor-rtmock/src/sleep_runtime.rs +4 −3 Original line number Diff line number Diff line Loading @@ -68,9 +68,10 @@ impl<R: Runtime> MockSleepRuntime<R> { /// Panics if another `WaitFor` future is already running. (If two ran simultaneously, they /// would both try and advance the same mock time clock, which would be bad.) pub fn wait_for<F: futures::Future>(&self, fut: F) -> WaitFor<F> { if self.sleep.has_waitfor_waker() { panic!("attempted to call MockSleepRuntime::wait_for while another WaitFor is active"); } assert!( !self.sleep.has_waitfor_waker(), "attempted to call MockSleepRuntime::wait_for while another WaitFor is active" ); WaitFor { sleep: self.sleep.clone(), fut, Loading
crates/tor-rtmock/src/time.rs +8 −6 Original line number Diff line number Diff line Loading @@ -196,12 +196,14 @@ impl MockSleepProvider { .peek() .map(|sleepent| sleepent.when.saturating_duration_since(now)) }; if next_timeout.is_none() { let next_timeout = match next_timeout { Some(x) => x, None => { // There's no timeout set, so we really shouldn't be here anyway. eprintln!("should_advance = false; allow_one set but no timeout yet"); return false; } let next_timeout = next_timeout.unwrap(); }; if next_timeout <= state.allowed_advance { // We can advance up to the next timeout, since it's in our quota. // Subtract the amount we're going to advance by from said quota. Loading