mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-15 19:31:35 +02:00
fuzz: Properly setup wallet in wallet_fees target
Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
This commit is contained in:
parent
cbd8e3d511
commit
fa427ffcee
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2022 The Bitcoin Core developers
|
// Copyright (c) 2022-present The Bitcoin Core developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@ -6,31 +6,31 @@
|
|||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
|
#include <validation.h>
|
||||||
#include <wallet/coincontrol.h>
|
#include <wallet/coincontrol.h>
|
||||||
#include <wallet/fees.h>
|
#include <wallet/fees.h>
|
||||||
#include <wallet/wallet.h>
|
|
||||||
#include <wallet/test/util.h>
|
#include <wallet/test/util.h>
|
||||||
#include <validation.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
namespace {
|
namespace {
|
||||||
const TestingSetup* g_setup;
|
const TestingSetup* g_setup;
|
||||||
static std::unique_ptr<CWallet> g_wallet_ptr;
|
|
||||||
|
|
||||||
void initialize_setup()
|
void initialize_setup()
|
||||||
{
|
{
|
||||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
|
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||||
g_setup = testing_setup.get();
|
g_setup = testing_setup.get();
|
||||||
const auto& node{g_setup->m_node};
|
|
||||||
g_wallet_ptr = std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET(wallet_fees, .init = initialize_setup)
|
FUZZ_TARGET(wallet_fees, .init = initialize_setup)
|
||||||
{
|
{
|
||||||
|
SeedRandomStateForTest(SeedRand::ZEROS);
|
||||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
const auto& node{g_setup->m_node};
|
const auto& node{g_setup->m_node};
|
||||||
Chainstate* chainstate = &node.chainman->ActiveChainstate();
|
Chainstate* chainstate = &node.chainman->ActiveChainstate();
|
||||||
CWallet& wallet = *g_wallet_ptr;
|
std::unique_ptr<CWallet> wallet_ptr{std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase())};
|
||||||
|
CWallet& wallet{*wallet_ptr};
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
wallet.SetLastBlockProcessed(chainstate->m_chain.Height(), chainstate->m_chain.Tip()->GetBlockHash());
|
wallet.SetLastBlockProcessed(chainstate->m_chain.Height(), chainstate->m_chain.Tip()->GetBlockHash());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user