aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/coins_view.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/fuzz/coins_view.cpp')
-rw-r--r--src/test/fuzz/coins_view.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
index 878b5a27da..f452696689 100644
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -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)
@@ -181,8 +183,8 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
}
{
- const CCoinsViewCursor* coins_view_cursor = backend_coins_view.Cursor();
- assert(coins_view_cursor == nullptr);
+ std::unique_ptr<CCoinsViewCursor> coins_view_cursor = backend_coins_view.Cursor();
+ assert(!coins_view_cursor);
(void)backend_coins_view.EstimateSize();
(void)backend_coins_view.GetBestBlock();
(void)backend_coins_view.GetHeadBlocks();
@@ -236,8 +238,9 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
// It is not allowed to call CheckTxInputs if CheckTransaction failed
return;
}
- (void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
- assert(MoneyRange(tx_fee_out));
+ if (Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out)) {
+ assert(MoneyRange(tx_fee_out));
+ }
},
[&] {
const CTransaction transaction{random_mutable_transaction};
@@ -267,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;
}