mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-07-05 11:40:07 +02:00
Merge bitcoin/bitcoin#35653: fuzz: Remove ConsumeUniValue
9f3e427228fuzz: Remove ConsumeUniValue (marcofleon) Pull request description: Addresses https://github.com/bitcoin/bitcoin/pull/35118#discussion_r3514230802. `ConsumeUniValue` isn't that useful as a shared fuzz helper, as it just returns the same hard-coded fields. This PR removes it and updates the `ipc` target to read a UniValue directly from fuzzer input instead. This is similar to what the `parse_univalue` target already does, and lets `ipc` test with different JSON values instead of one fixed value. ACKs for top commit: sedited: ACK9f3e427228brunoerg: code review ACK9f3e427228Tree-SHA512: 5bc0957c426b185392aabf5c74411758e93bc8e75e9896b08774b33d5ec8ba9c223499a139b03a94dcf907b73552962df9a9b059e875f40048707a87a69bf7c5
This commit is contained in:
@@ -123,7 +123,8 @@ FUZZ_TARGET(ipc, .init = initialize_ipc)
|
||||
assert(ipc.m_client->passScript(script) == expected);
|
||||
},
|
||||
[&] {
|
||||
UniValue value = ConsumeUniValue(fuzzed_data_provider);
|
||||
UniValue value;
|
||||
if (!value.read(fuzzed_data_provider.ConsumeRandomLengthString(512))) return;
|
||||
assert(ipc.m_client->passUniValue(value).write() == value.write());
|
||||
},
|
||||
[&] {
|
||||
|
||||
@@ -237,16 +237,6 @@ CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<b
|
||||
return key;
|
||||
}
|
||||
|
||||
UniValue ConsumeUniValue(FuzzedDataProvider& fuzzed_data_provider) noexcept
|
||||
{
|
||||
UniValue value{UniValue::VOBJ};
|
||||
value.pushKV("bool", fuzzed_data_provider.ConsumeBool());
|
||||
value.pushKV("number", fuzzed_data_provider.ConsumeIntegralInRange<int>(-1'000'000, 1'000'000));
|
||||
value.pushKV("string", "ipc fuzz");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool ContainsSpentInput(const CTransaction& tx, const CCoinsViewCache& inputs) noexcept
|
||||
{
|
||||
for (const CTxIn& tx_in : tx.vin) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#ifndef BITCOIN_TEST_FUZZ_UTIL_H
|
||||
#define BITCOIN_TEST_FUZZ_UTIL_H
|
||||
|
||||
#include <univalue.h>
|
||||
#include <addresstype.h>
|
||||
#include <arith_uint256.h>
|
||||
#include <coins.h>
|
||||
@@ -229,8 +228,6 @@ template <class Dur>
|
||||
|
||||
[[nodiscard]] CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<bool> compressed = std::nullopt) noexcept;
|
||||
|
||||
[[nodiscard]] UniValue ConsumeUniValue(FuzzedDataProvider& fuzzed_data_provider) noexcept;
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user