mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 19:47:53 +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:
@@ -6,6 +6,7 @@
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/time.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <validation.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
@@ -62,7 +63,7 @@ FUZZ_TARGET(wallet_fees, .init = initialize_setup)
|
||||
{
|
||||
SeedRandomStateForTest(SeedRand::ZEROS);
|
||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
|
||||
auto& node{g_setup->m_node};
|
||||
Chainstate* chainstate = &node.chainman->ActiveChainstate();
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/fuzz/util/descriptor.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/time.h>
|
||||
#include <util/check.h>
|
||||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
@@ -78,7 +79,7 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm)
|
||||
{
|
||||
SeedRandomStateForTest(SeedRand::ZEROS);
|
||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
|
||||
const auto& node{g_setup->m_node};
|
||||
Chainstate& chainstate{node.chainman->ActiveChainstate()};
|
||||
std::unique_ptr<CWallet> wallet_ptr{std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase())};
|
||||
|
||||
@@ -2,20 +2,21 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <addresstype.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/fuzz/util/wallet.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/time.h>
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <wallet/context.h>
|
||||
#include <wallet/spend.h>
|
||||
#include <wallet/test/util.h>
|
||||
#include <wallet/wallet.h>
|
||||
#include <validation.h>
|
||||
#include <addresstype.h>
|
||||
|
||||
using util::ToString;
|
||||
|
||||
@@ -33,7 +34,7 @@ FUZZ_TARGET(wallet_create_transaction, .init = initialize_setup)
|
||||
{
|
||||
SeedRandomStateForTest(SeedRand::ZEROS);
|
||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
NodeClockContext clock_ctx{ConsumeTime(fuzzed_data_provider)};
|
||||
const auto& node = g_setup->m_node;
|
||||
Chainstate& chainstate{node.chainman->ActiveChainstate()};
|
||||
ArgsManager& args = *node.args;
|
||||
|
||||
Reference in New Issue
Block a user