Skip to content

Commit fa40d6a

Browse files
author
MarcoFalke
committed
test: Reset mocktime in the common setup
Doing it there will reduce code bloat and also ensure no test can "forget" to reset it
1 parent fa78590 commit fa40d6a

File tree

6 files changed

+1
-13
lines changed

6 files changed

+1
-13
lines changed

src/test/denialofservice_tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
116116
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect
117117
}
118118
BOOST_CHECK(dummyNode1.fDisconnect == true);
119-
SetMockTime(0);
120119

121120
peerLogic->FinalizeNode(dummyNode1);
122121
}

src/test/logging_tests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ BOOST_FIXTURE_TEST_SUITE(logging_tests, BasicTestingSetup)
1414

1515
BOOST_AUTO_TEST_CASE(logging_timer)
1616
{
17-
1817
SetMockTime(1);
1918
auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
2019
SetMockTime(2);
@@ -29,8 +28,6 @@ BOOST_AUTO_TEST_CASE(logging_timer)
2928
auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg");
3029
SetMockTime(2);
3130
BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000.00μs)");
32-
33-
SetMockTime(0);
3431
}
3532

3633
BOOST_AUTO_TEST_SUITE_END()

src/test/mempool_tests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,6 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
571571
SetMockTime(42 + 8*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLIFE/2 + CTxMemPool::ROLLING_FEE_HALFLIFE/4);
572572
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 0);
573573
// ... unless it has gone all the way to 0 (after getting past 1000/2)
574-
575-
SetMockTime(0);
576574
}
577575

578576
inline CTransactionRef make_tx(std::vector<CAmount>&& output_values, std::vector<CTransactionRef>&& inputs=std::vector<CTransactionRef>(), std::vector<uint32_t>&& input_indices=std::vector<uint32_t>())

src/test/rpc_tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ BOOST_AUTO_TEST_CASE(rpc_ban)
335335
o1 = ar[0].get_obj();
336336
adr = find_value(o1, "address");
337337
BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128");
338-
SetMockTime(0s);
339338
}
340339

341340
BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress)

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
120120

121121
BasicTestingSetup::~BasicTestingSetup()
122122
{
123+
SetMockTime(0s); // Reset mocktime for following tests
123124
LogInstance().DisconnectTestLogger();
124125
fs::remove_all(m_path_root);
125126
gArgs.ClearArgs();
@@ -303,7 +304,6 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
303304
TestChain100Setup::~TestChain100Setup()
304305
{
305306
gArgs.ForceSetArg("-segwitheight", "0");
306-
SetMockTime(0);
307307
}
308308

309309
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const

src/wallet/test/wallet_tests.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
295295
BOOST_CHECK_EQUAL(found, expected);
296296
}
297297
}
298-
299-
SetMockTime(0);
300298
}
301299

302300
// Check that GetImmatureCredit() returns a newly calculated value instead of
@@ -377,9 +375,6 @@ BOOST_AUTO_TEST_CASE(ComputeTimeSmart)
377375
// If there are future entries, new transaction should use time of the
378376
// newest entry that is no more than 300 seconds ahead of the clock time.
379377
BOOST_CHECK_EQUAL(AddTx(*m_node.chainman, m_wallet, 5, 50, 600), 300);
380-
381-
// Reset mock time for other tests.
382-
SetMockTime(0);
383378
}
384379

385380
BOOST_AUTO_TEST_CASE(LoadReceiveRequests)

0 commit comments

Comments
 (0)