mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
test: Reset mocktime in the common setup
Doing it there will reduce code bloat and also ensure no test can "forget" to reset it
This commit is contained in:
parent
fa78590a8f
commit
fa40d6a1c4
6 changed files with 1 additions and 13 deletions
|
@ -116,7 +116,6 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||||
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect
|
BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect
|
||||||
}
|
}
|
||||||
BOOST_CHECK(dummyNode1.fDisconnect == true);
|
BOOST_CHECK(dummyNode1.fDisconnect == true);
|
||||||
SetMockTime(0);
|
|
||||||
|
|
||||||
peerLogic->FinalizeNode(dummyNode1);
|
peerLogic->FinalizeNode(dummyNode1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ BOOST_FIXTURE_TEST_SUITE(logging_tests, BasicTestingSetup)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(logging_timer)
|
BOOST_AUTO_TEST_CASE(logging_timer)
|
||||||
{
|
{
|
||||||
|
|
||||||
SetMockTime(1);
|
SetMockTime(1);
|
||||||
auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
|
auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
|
||||||
SetMockTime(2);
|
SetMockTime(2);
|
||||||
|
@ -29,8 +28,6 @@ BOOST_AUTO_TEST_CASE(logging_timer)
|
||||||
auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg");
|
auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg");
|
||||||
SetMockTime(2);
|
SetMockTime(2);
|
||||||
BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000.00μs)");
|
BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000.00μs)");
|
||||||
|
|
||||||
SetMockTime(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
@ -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);
|
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);
|
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 0);
|
||||||
// ... unless it has gone all the way to 0 (after getting past 1000/2)
|
// ... unless it has gone all the way to 0 (after getting past 1000/2)
|
||||||
|
|
||||||
SetMockTime(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>())
|
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>())
|
||||||
|
|
|
@ -335,7 +335,6 @@ BOOST_AUTO_TEST_CASE(rpc_ban)
|
||||||
o1 = ar[0].get_obj();
|
o1 = ar[0].get_obj();
|
||||||
adr = find_value(o1, "address");
|
adr = find_value(o1, "address");
|
||||||
BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128");
|
BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128");
|
||||||
SetMockTime(0s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress)
|
BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress)
|
||||||
|
|
|
@ -120,6 +120,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||||
|
|
||||||
BasicTestingSetup::~BasicTestingSetup()
|
BasicTestingSetup::~BasicTestingSetup()
|
||||||
{
|
{
|
||||||
|
SetMockTime(0s); // Reset mocktime for following tests
|
||||||
LogInstance().DisconnectTestLogger();
|
LogInstance().DisconnectTestLogger();
|
||||||
fs::remove_all(m_path_root);
|
fs::remove_all(m_path_root);
|
||||||
gArgs.ClearArgs();
|
gArgs.ClearArgs();
|
||||||
|
@ -303,7 +304,6 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
|
||||||
TestChain100Setup::~TestChain100Setup()
|
TestChain100Setup::~TestChain100Setup()
|
||||||
{
|
{
|
||||||
gArgs.ForceSetArg("-segwitheight", "0");
|
gArgs.ForceSetArg("-segwitheight", "0");
|
||||||
SetMockTime(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
|
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
|
||||||
|
|
|
@ -295,8 +295,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
||||||
BOOST_CHECK_EQUAL(found, expected);
|
BOOST_CHECK_EQUAL(found, expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMockTime(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that GetImmatureCredit() returns a newly calculated value instead of
|
// Check that GetImmatureCredit() returns a newly calculated value instead of
|
||||||
|
@ -377,9 +375,6 @@ BOOST_AUTO_TEST_CASE(ComputeTimeSmart)
|
||||||
// If there are future entries, new transaction should use time of the
|
// 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.
|
// 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);
|
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)
|
BOOST_AUTO_TEST_CASE(LoadReceiveRequests)
|
||||||
|
|
Loading…
Reference in a new issue