mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-09 23:27:23 +02:00
fuzz: Use NodeClockContext
This refactor does not change any behavior. However, it is nice to know that no global mocktime leaks from the fuzz init step to the first fuzz input, or from one fuzz input execution to the next. With the clock context, the global is re-set at the end of the context.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <test/util/mining.h>
|
||||
#include <test/util/net.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/time.h>
|
||||
#include <test/util/validation.h>
|
||||
#include <util/check.h>
|
||||
#include <util/time.h>
|
||||
@@ -75,7 +76,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
connman.Reset();
|
||||
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
|
||||
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
|
||||
SetMockTime(1610000000); // any time to successfully reset ibd
|
||||
NodeClockContext clock_ctx{1610000000s}; // any time to successfully reset ibd
|
||||
chainman.ResetIbd();
|
||||
chainman.DisableNextWrite();
|
||||
|
||||
@@ -105,8 +106,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
connman.AddTestNode(p2p_node);
|
||||
FillNode(fuzzed_data_provider, connman, p2p_node);
|
||||
|
||||
const auto mock_time = ConsumeTime(fuzzed_data_provider);
|
||||
SetMockTime(mock_time);
|
||||
clock_ctx.set(ConsumeTime(fuzzed_data_provider));
|
||||
|
||||
CSerializedNetMsg net_msg;
|
||||
net_msg.m_type = random_message_type;
|
||||
|
||||
Reference in New Issue
Block a user