Skip to content

Commit

Permalink
fix(test_utils): recover from lock poisoning in tests (#18)
Browse files Browse the repository at this point in the history
Small fix so that when a test thread panics (which happens when an
`assert_eq` evaluates to `false`), we recover from it and all other
tests continue running. Otherwise, the lock gets poisoned, we `unwrap`
and all the other tests fail.
  • Loading branch information
alexfertel authored Mar 29, 2024
1 parent a5d084a commit 9f79e79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) static STORAGE_MUTEX: Mutex<()> = Mutex::new(());

/// Acquires access to storage.
pub(crate) fn acquire_storage() -> MutexGuard<'static, ()> {
STORAGE_MUTEX.lock().unwrap()
STORAGE_MUTEX.lock().unwrap_or_else(|e| e.into_inner())
}

/// Decorates a closure by running it with exclusive access to storage.
Expand Down

0 comments on commit 9f79e79

Please sign in to comment.