fix(net)!: remove Drop assertions for any unused plans
Some checks failed
Test / build (map[name:nightly]) (push) Failing after 11m4s
Test / build (map[name:stable]) (push) Failing after 1m33s

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:
Paul Campbell 2024-12-28 17:48:27 +00:00
parent 9b7a2870ff
commit a18e300b50

View file

@ -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() {