Seems the way to do it would be:
diff --git a/src/wallet/test/fuzz/fees.cpp b/src/wallet/test/fuzz/fees.cpp
index c4e1b7d61..fc9b6a5e4 100644
--- a/src/wallet/test/fuzz/fees.cpp
+++ b/src/wallet/test/fuzz/fees.cpp
@@ -15,23 +15,27 @@
namespace wallet {
namespace {
const TestingSetup* g_setup;
+static std::unique_ptr<CWallet> wallet_ptr;
+static Chainstate* chainstate = nullptr;
void initialize_setup()
{
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
g_setup = testing_setup.get();
+ const auto& node{g_setup->m_node};
+ chainstate = &node.chainman->ActiveChainstate();
+ wallet_ptr = std::make_unique<CWallet>(node.chain.get(), "", CreateDummyWalletDatabase());
}
FUZZ_TARGET_INIT(wallet_fees, initialize_setup)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
CMutableTransaction random_mutable_transaction;
- const auto& node{g_setup->m_node};
- const auto& chainstate{node.chainman->ActiveChainstate()};
- static CWallet wallet(node.chain.get(), "", CreateDummyWalletDatabase());
+
+ CWallet& wallet = *wallet_ptr;
{
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());
}
if (fuzzed_data_provider.ConsumeBool()) {
Seems reasonable? Any alternative?