From fa9af06d91e9357e86863781746f0e78a509967e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 21 Feb 2020 09:20:51 -0800 Subject: scripted-diff: Replace MilliSleep with UninterruptibleSleep This is safe because MilliSleep is never executed in a boost::thread, the only type of thread that is interruptible. * The RPC server uses std::thread * The wallet is either executed in an RPC thread or the main thread * bitcoin-cli, benchmarks and tests are only one thread (the main thread) -BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/MilliSleep\((\S+)\);/UninterruptibleSleep(std::chrono::milliseconds{\1});/g' $(git grep -l MilliSleep) -END VERIFY SCRIPT- --- src/test/util_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test/util_tests.cpp') diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 42c2c50fa..949d8e667 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1322,7 +1322,7 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime) SetMockTime(111); // Check that mock time does not change after a sleep for (const auto& num_sleep : {0, 1}) { - MilliSleep(num_sleep); + UninterruptibleSleep(std::chrono::milliseconds{num_sleep}); BOOST_CHECK_EQUAL(111, GetTime()); // Deprecated time getter BOOST_CHECK_EQUAL(111, GetTime().count()); BOOST_CHECK_EQUAL(111000, GetTime().count()); @@ -1333,7 +1333,7 @@ BOOST_AUTO_TEST_CASE(util_time_GetTime) // Check that system time changes after a sleep const auto ms_0 = GetTime(); const auto us_0 = GetTime(); - MilliSleep(1); + UninterruptibleSleep(std::chrono::milliseconds{1}); BOOST_CHECK(ms_0 < GetTime()); BOOST_CHECK(us_0 < GetTime()); } -- cgit v1.2.3