From a18e300b504acec768853e19d8d9dfffa1339f65 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 28 Dec 2024 17:48:27 +0000 Subject: [PATCH] fix(net)!: remove Drop assertions for any unused plans Tests should use the existing `assert_no_unused_plans` method available on both `Net` and `MockNet`. This removes the problem of assetions being applied early when there are multiple clones of the `Net` or `MockNet` and one of them is dropped. --- src/net/system.rs | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/net/system.rs b/src/net/system.rs index c35e75d..4f53de1 100644 --- a/src/net/system.rs +++ b/src/net/system.rs @@ -628,47 +628,6 @@ impl From for Net { } } -impl Drop for MockNet { - #[cfg_attr(test, mutants::skip)] - #[tracing::instrument] - fn drop(&mut self) { - // Don't assert during panic to avoid double panic - if std::thread::panicking() { - return; - } - let unused = self.plans.take(); - if !unused.is_empty() { - log_unused_plans(&unused); - assert!( - unused.is_empty(), - "{} expected requests were not made", - unused.len() - ); - } - } -} -impl Drop for Net { - #[cfg_attr(test, mutants::skip)] - #[tracing::instrument] - fn drop(&mut self) { - // Don't assert during panic to avoid double panic - if std::thread::panicking() { - return; - } - if let Some(plans) = &self.plans { - let unused = plans.try_lock().expect("lock plans").take(); - if !unused.is_empty() { - log_unused_plans(&unused); - assert!( - unused.is_empty(), - "{} expected requests were not made", - unused.len() - ); - } - } - } -} - #[cfg_attr(test, mutants::skip)] fn log_unused_plans(unused: &[Plan]) { if !unused.is_empty() {