Skip to content

Commit 1835f2f

Browse files
committed
Merge bitcoin#35653: fuzz: Remove ConsumeUniValue
9f3e427 fuzz: Remove ConsumeUniValue (marcofleon) Pull request description: Addresses bitcoin#35118 (comment). `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: ACK 9f3e427 brunoerg: code review ACK 9f3e427 Tree-SHA512: 5bc0957c426b185392aabf5c74411758e93bc8e75e9896b08774b33d5ec8ba9c223499a139b03a94dcf907b73552962df9a9b059e875f40048707a87a69bf7c5
2 parents 32ddfc9 + 9f3e427 commit 1835f2f

3 files changed

Lines changed: 2 additions & 14 deletions

File tree

src/ipc/test/fuzz/ipc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ FUZZ_TARGET(ipc, .init = initialize_ipc)
123123
assert(ipc.m_client->passScript(script) == expected);
124124
},
125125
[&] {
126-
UniValue value = ConsumeUniValue(fuzzed_data_provider);
126+
UniValue value;
127+
if (!value.read(fuzzed_data_provider.ConsumeRandomLengthString(512))) return;
127128
assert(ipc.m_client->passUniValue(value).write() == value.write());
128129
},
129130
[&] {

src/test/fuzz/util.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,6 @@ CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<b
237237
return key;
238238
}
239239

240-
UniValue ConsumeUniValue(FuzzedDataProvider& fuzzed_data_provider) noexcept
241-
{
242-
UniValue value{UniValue::VOBJ};
243-
value.pushKV("bool", fuzzed_data_provider.ConsumeBool());
244-
value.pushKV("number", fuzzed_data_provider.ConsumeIntegralInRange<int>(-1'000'000, 1'000'000));
245-
value.pushKV("string", "ipc fuzz");
246-
247-
return value;
248-
}
249-
250240
bool ContainsSpentInput(const CTransaction& tx, const CCoinsViewCache& inputs) noexcept
251241
{
252242
for (const CTxIn& tx_in : tx.vin) {

src/test/fuzz/util.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef BITCOIN_TEST_FUZZ_UTIL_H
66
#define BITCOIN_TEST_FUZZ_UTIL_H
77

8-
#include <univalue.h>
98
#include <addresstype.h>
109
#include <arith_uint256.h>
1110
#include <coins.h>
@@ -229,8 +228,6 @@ template <class Dur>
229228

230229
[[nodiscard]] CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<bool> compressed = std::nullopt) noexcept;
231230

232-
[[nodiscard]] UniValue ConsumeUniValue(FuzzedDataProvider& fuzzed_data_provider) noexcept;
233-
234231
template <typename T>
235232
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept
236233
{

0 commit comments

Comments
 (0)