diff --git a/test/object-store/realm.cpp b/test/object-store/realm.cpp index ac70a115fd2..8f111954553 100644 --- a/test/object-store/realm.cpp +++ b/test/object-store/realm.cpp @@ -1177,12 +1177,10 @@ TEST_CASE("SharedRealm: async writes") { auto write = db->start_write(); sema.add_stone(); - // We want to wait until the main thread is waiting for the - // lock, which we can't do deterministically. If this sleep - // is too short the test will still pass and it'll just fail - // to test the intended code path. - std::chrono::milliseconds wait_time{500}; - std::this_thread::sleep_for(wait_time); + // Wait until the main thread is waiting for the lock. + while (!db->waiting_for_write_lock()) { + millisleep(1); + } write->close(); });