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 :)
This commit is contained in:
Joonas Koivunen 2020-08-11 13:51:17 +03:00
parent 9e695e02cb
commit c95a9bb862

View File

@ -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);
}