Apply same pattern
MODIFY
WalletWasabi.Tests/UnitTests/IoTests.cs
WalletWasabi.Tests/UnitTests/IoTests.cs
@@ -117,18 +117,21 @@ namespace WalletWasabi.Tests.UnitTests
// Mutex tests.
+ using (ManualResetEvent locked = new ManualResetEvent(false))
+ {
// Acquire the Mutex with a background thread.
var myTask = Task.Run(async () =>
{
using (await ioman1.Mutex.LockAsync())
{
+ locked.Set();
await Task.Delay(3000);
}
});
// Wait for the Task.Run to Acquire the Mutex.
- await Task.Delay(100);
+ Assert.True(locked.WaitOne(TimeSpan.FromSeconds(5)));
// Try to get the Mutex and save the time.
DateTime timeOfstart = DateTime.Now;
@@ -143,7 +146,7 @@ namespace WalletWasabi.Tests.UnitTests
var elapsed = timeOfAcquired - timeOfstart;
Assert.InRange(elapsed, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4));
-
+ }
// Simulate file write error and recovery logic.
// We have only *.new and *.old files.

Apply same pattern