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.
This commit is contained in:
parent
9b7a2870ff
commit
a18e300b50
1 changed files with 0 additions and 41 deletions
|
@ -628,47 +628,6 @@ impl From<MockNet> 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() {
|
||||
|
|
Loading…
Reference in a new issue