Skip to content

Commit fa427ff

Browse files
MarcoFalkehebasto
andcommitted
fuzz: Properly setup wallet in wallet_fees target
Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
1 parent cbd8e3d commit fa427ff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/wallet/test/fuzz/fees.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
// Copyright (c) 2022 The Bitcoin Core developers
1+
// Copyright (c) 2022-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <test/fuzz/FuzzedDataProvider.h>
66
#include <test/fuzz/fuzz.h>
77
#include <test/fuzz/util.h>
88
#include <test/util/setup_common.h>
9+
#include <validation.h>
910
#include <wallet/coincontrol.h>
1011
#include <wallet/fees.h>
11-
#include <wallet/wallet.h>
1212
#include <wallet/test/util.h>
13-
#include <validation.h>
13+
#include <wallet/wallet.h>
1414

1515
namespace wallet {
1616
namespace {
1717
const TestingSetup* g_setup;
18-
static std::unique_ptr<CWallet> g_wallet_ptr;
1918

2019
void initialize_setup()
2120
{
2221
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
2322
g_setup = testing_setup.get();
24-
const auto& node{g_setup->m_node};
25-
g_wallet_ptr = std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase());
2623
}
2724

2825
FUZZ_TARGET(wallet_fees, .init = initialize_setup)
2926
{
27+
SeedRandomStateForTest(SeedRand::ZEROS);
3028
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
29+
SetMockTime(ConsumeTime(fuzzed_data_provider));
3130
const auto& node{g_setup->m_node};
3231
Chainstate* chainstate = &node.chainman->ActiveChainstate();
33-
CWallet& wallet = *g_wallet_ptr;
32+
std::unique_ptr<CWallet> wallet_ptr{std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase())};
33+
CWallet& wallet{*wallet_ptr};
3434
{
3535
LOCK(wallet.cs_wallet);
3636
wallet.SetLastBlockProcessed(chainstate->m_chain.Height(), chainstate->m_chain.Tip()->GetBlockHash());

0 commit comments

Comments
 (0)