mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
fuzz: Initialize a TestingSetup for test_one_input
For fuzz tests that need it.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
const TestingSetup* g_setup;
|
||||
const Coin EMPTY_COIN{};
|
||||
|
||||
bool operator==(const Coin& a, const Coin& b)
|
||||
@@ -39,6 +40,7 @@ bool operator==(const Coin& a, const Coin& b)
|
||||
void initialize_coins_view()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||
g_setup = testing_setup.get();
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
|
||||
@@ -268,7 +270,7 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
|
||||
CCoinsStats stats{CoinStatsHashType::HASH_SERIALIZED};
|
||||
bool expected_code_path = false;
|
||||
try {
|
||||
(void)GetUTXOStats(&coins_view_cache, WITH_LOCK(::cs_main, return std::ref(g_chainman.m_blockman)), stats);
|
||||
(void)GetUTXOStats(&coins_view_cache, WITH_LOCK(::cs_main, return std::ref(g_setup->m_node.chainman->m_blockman)), stats);
|
||||
} catch (const std::logic_error&) {
|
||||
expected_code_path = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user