From c95a9bb8627f44827f14cf281fbe6759faab3688 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Tue, 11 Aug 2020 13:51:17 +0300 Subject: [PATCH] fix: first drop mutex guard, then assert the assert while holding the guard poisons the mutex and that causes drop to panic because of the poisoned mutex, by design; see last commit. by shortening the scope of the mutex guard we should once again see more clear build failures :) --- tests/wantlist_and_cancellation.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/wantlist_and_cancellation.rs b/tests/wantlist_and_cancellation.rs index b02b48d5..b64e31f5 100644 --- a/tests/wantlist_and_cancellation.rs +++ b/tests/wantlist_and_cancellation.rs @@ -38,11 +38,13 @@ where } async fn check_cid_subscriptions(ipfs: &Node, cid: &Cid, expected_count: usize) { - let subs = ipfs.get_subscriptions().lock().unwrap(); - if expected_count > 0 { - assert_eq!(subs.len(), 1); - } - let subscription_count = subs.get(&cid.clone().into()).map(|l| l.len()); + let subscription_count = { + let subs = ipfs.get_subscriptions().lock().unwrap(); + if expected_count > 0 { + assert_eq!(subs.len(), 1); + } + subs.get(&cid.clone().into()).map(|l| l.len()) + }; // treat None as 0 assert_eq!(subscription_count.unwrap_or(0), expected_count); }