diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index 0ae1ad5c31..30e05e4ee1 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -113,7 +113,6 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect } BOOST_CHECK(dummyNode1.fDisconnect == true); - SetMockTime(0); peerLogic->FinalizeNode(dummyNode1); } diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index 09a05c3701..e2e31c62d7 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -14,7 +14,6 @@ BOOST_FIXTURE_TEST_SUITE(logging_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(logging_timer) { - SetMockTime(1); auto sec_timer = BCLog::Timer("tests", "end_msg"); SetMockTime(2); @@ -29,8 +28,6 @@ BOOST_AUTO_TEST_CASE(logging_timer) auto micro_timer = BCLog::Timer("tests", "end_msg"); SetMockTime(2); BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000μs)"); - - SetMockTime(0); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 3ea1c9fac1..e66bedef05 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -571,8 +571,6 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) SetMockTime(42 + 8*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4); BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 0); // ... unless it has gone all the way to 0 (after getting past 1000/2) - - SetMockTime(0); } inline CTransactionRef make_tx(std::vector&& output_values, std::vector&& inputs=std::vector(), std::vector&& input_indices=std::vector()) diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 3208da076b..44b3c8fae6 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -323,7 +323,11 @@ BOOST_AUTO_TEST_CASE(rpc_ban) BOOST_CHECK_NO_THROW(CallRPC(std::string("clearbanned"))); + auto now = 10'000s; + SetMockTime(now); BOOST_CHECK_NO_THROW(r = CallRPC(std::string("setban 127.0.0.0/24 add 200"))); + SetMockTime(now += 2s); + const int64_t time_remaining_expected{198}; BOOST_CHECK_NO_THROW(r = CallRPC(std::string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); @@ -332,12 +336,10 @@ BOOST_AUTO_TEST_CASE(rpc_ban) const int64_t ban_created{find_value(o1, "ban_created").get_int64()}; const int64_t ban_duration{find_value(o1, "ban_duration").get_int64()}; const int64_t time_remaining{find_value(o1, "time_remaining").get_int64()}; - const int64_t now{GetTime()}; BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/24"); - BOOST_CHECK(banned_until > now); - BOOST_CHECK(banned_until - now <= 200); + BOOST_CHECK_EQUAL(banned_until, time_remaining_expected + now.count()); BOOST_CHECK_EQUAL(ban_duration, banned_until - ban_created); - BOOST_CHECK_EQUAL(time_remaining, banned_until - now); + BOOST_CHECK_EQUAL(time_remaining, time_remaining_expected); // must throw an exception because 127.0.0.1 is in already banned subnet range BOOST_CHECK_THROW(r = CallRPC(std::string("setban 127.0.0.1 add")), std::runtime_error); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index d40b0ecb7a..2780624056 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -195,6 +195,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve BasicTestingSetup::~BasicTestingSetup() { + SetMockTime(0s); // Reset mocktime for following tests connman.reset(); llmq::quorumSnapshotManager.reset(); m_node.cpoolman.reset(); @@ -498,7 +499,6 @@ TestChainSetup::~TestChainSetup() g_txindex->Stop(); SyncWithValidationInterfaceQueue(); g_txindex.reset(); - SetMockTime(0); } CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 6fc3fd3006..c470c33428 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -315,8 +315,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) BOOST_CHECK_EQUAL(found, expected); } } - - SetMockTime(0); } // Verify getaddressinfo RPC produces more or less expected results @@ -473,9 +471,6 @@ BOOST_AUTO_TEST_CASE(ComputeTimeSmart) // If there are future entries, new transaction should use time of the // newest entry that is no more than 300 seconds ahead of the clock time. BOOST_CHECK_EQUAL(AddTx(*m_node.chainman, m_wallet, 5, 50, 600), 300); - - // Reset mock time for other tests. - SetMockTime(0); } BOOST_AUTO_TEST_CASE(LoadReceiveRequests)