mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-21 19:34:20 +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:
@@ -14,6 +14,7 @@
|
||||
#include <test/fuzz/util/net.h>
|
||||
#include <test/util/net.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/time.h>
|
||||
#include <util/asmap.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/time.h>
|
||||
@@ -31,7 +32,7 @@ void initialize_net()
|
||||
FUZZ_TARGET(net, .init = initialize_net)
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
|
||||
CNode node{ConsumeNode(fuzzed_data_provider)};
|
||||
node.SetCommonVersion(fuzzed_data_provider.ConsumeIntegral<int>());
|
||||
if (const auto service_opt =
|
||||
@@ -80,7 +81,7 @@ FUZZ_TARGET(net, .init = initialize_net)
|
||||
FUZZ_TARGET(local_address, .init = initialize_net)
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
|
||||
CService service{ConsumeService(fuzzed_data_provider)};
|
||||
CNode node{ConsumeNode(fuzzed_data_provider)};
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user