0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

fuzz: Remove useless GetUTXOStats fuzz case

In the GetUTXOStats fuzz case, GetUTXOStats is always called with a
CCoinsViewCache. Which is guaranteed to throw a std::logic_error when
its ::Cursor() method is called on the first line of GetUTXOStats.

In the fuzz case, we basically catch this logic error and declare
victory if we caught it.

There is no point to fuzzing this deterministic logic.

Confirmed with IWYU that the node/coinstats.h #include is no longer
necessary.
This commit is contained in:
Carl Dong 2022-04-29 13:30:27 -04:00
parent 52b1939993
commit 0848db9c35

View file

@ -10,7 +10,6 @@
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <key.h>
#include <node/coinstats.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <pubkey.h>
@ -26,10 +25,6 @@
#include <string>
#include <vector>
using node::CCoinsStats;
using node::CoinStatsHashType;
using node::GetUTXOStats;
namespace {
const TestingSetup* g_setup;
const Coin EMPTY_COIN{};
@ -269,16 +264,6 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
}
(void)GetTransactionSigOpCost(transaction, coins_view_cache, flags);
},
[&] {
CCoinsStats stats{CoinStatsHashType::HASH_SERIALIZED};
bool expected_code_path = false;
try {
(void)GetUTXOStats(&coins_view_cache, g_setup->m_node.chainman->m_blockman, stats);
} catch (const std::logic_error&) {
expected_code_path = true;
}
assert(expected_code_path);
},
[&] {
(void)IsWitnessStandard(CTransaction{random_mutable_transaction}, coins_view_cache);
});