Skip to content

Commit fa7809a

Browse files
author
MarcoFalke
committed
fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS)
1 parent 78f1bff commit fa7809a

31 files changed

+48
-3
lines changed

src/test/fuzz/addrman.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void initialize_addrman()
4141

4242
FUZZ_TARGET(data_stream_addr_man, .init = initialize_addrman)
4343
{
44+
SeedRandomStateForTest(SeedRand::ZEROS);
4445
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
4546
DataStream data_stream = ConsumeDataStream(fuzzed_data_provider);
4647
NetGroupManager netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)};
@@ -113,6 +114,7 @@ void FillAddrman(AddrMan& addrman, FuzzedDataProvider& fuzzed_data_provider)
113114

114115
FUZZ_TARGET(addrman, .init = initialize_addrman)
115116
{
117+
SeedRandomStateForTest(SeedRand::ZEROS);
116118
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
117119
SetMockTime(ConsumeTime(fuzzed_data_provider));
118120
NetGroupManager netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)};
@@ -197,6 +199,7 @@ FUZZ_TARGET(addrman, .init = initialize_addrman)
197199
// Check that serialize followed by unserialize produces the same addrman.
198200
FUZZ_TARGET(addrman_serdeser, .init = initialize_addrman)
199201
{
202+
SeedRandomStateForTest(SeedRand::ZEROS);
200203
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
201204
SetMockTime(ConsumeTime(fuzzed_data_provider));
202205

src/test/fuzz/banman.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static bool operator==(const CBanEntry& lhs, const CBanEntry& rhs)
4242

4343
FUZZ_TARGET(banman, .init = initialize_banman)
4444
{
45+
SeedRandomStateForTest(SeedRand::ZEROS);
4546
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
4647
SetMockTime(ConsumeTime(fuzzed_data_provider));
4748
fs::path banlist_file = gArgs.GetDataDirNet() / "fuzzed_banlist";

src/test/fuzz/blockfilter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <test/fuzz/FuzzedDataProvider.h>
77
#include <test/fuzz/fuzz.h>
88
#include <test/fuzz/util.h>
9+
#include <test/util/random.h>
910

1011
#include <cstdint>
1112
#include <optional>
@@ -14,6 +15,7 @@
1415

1516
FUZZ_TARGET(blockfilter)
1617
{
18+
SeedRandomStateForTest(SeedRand::ZEROS);
1719
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
1820
const std::optional<BlockFilter> block_filter = ConsumeDeserializable<BlockFilter>(fuzzed_data_provider);
1921
if (!block_filter) {

src/test/fuzz/connman.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void initialize_connman()
3636

3737
FUZZ_TARGET(connman, .init = initialize_connman)
3838
{
39+
SeedRandomStateForTest(SeedRand::ZEROS);
3940
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
4041
SetMockTime(ConsumeTime(fuzzed_data_provider));
4142
auto netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)};

src/test/fuzz/golomb_rice.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <test/fuzz/FuzzedDataProvider.h>
99
#include <test/fuzz/fuzz.h>
1010
#include <test/fuzz/util.h>
11+
#include <test/util/random.h>
1112
#include <util/bytevectorhash.h>
1213
#include <util/golombrice.h>
1314

@@ -42,6 +43,7 @@ std::vector<uint64_t> BuildHashedSet(const std::unordered_set<std::vector<uint8_
4243

4344
FUZZ_TARGET(golomb_rice)
4445
{
46+
SeedRandomStateForTest(SeedRand::ZEROS);
4547
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
4648
std::vector<uint8_t> golomb_rice_data;
4749
std::vector<uint64_t> encoded_deltas;

src/test/fuzz/headerssync.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class FuzzedHeadersSyncState : public HeadersSyncState
4848

4949
FUZZ_TARGET(headers_sync_state, .init = initialize_headers_sync_state_fuzz)
5050
{
51+
SeedRandomStateForTest(SeedRand::ZEROS);
5152
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
5253
auto mock_time{ConsumeTime(fuzzed_data_provider)};
5354

src/test/fuzz/i2p.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void initialize_i2p()
2121

2222
FUZZ_TARGET(i2p, .init = initialize_i2p)
2323
{
24+
SeedRandomStateForTest(SeedRand::ZEROS);
2425
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
2526

2627
SetMockTime(ConsumeTime(fuzzed_data_provider));

src/test/fuzz/key.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <test/fuzz/FuzzedDataProvider.h>
1919
#include <test/fuzz/fuzz.h>
2020
#include <test/fuzz/util.h>
21+
#include <test/util/random.h>
2122
#include <util/chaintype.h>
2223
#include <util/strencodings.h>
2324

@@ -38,6 +39,7 @@ void initialize_key()
3839

3940
FUZZ_TARGET(key, .init = initialize_key)
4041
{
42+
SeedRandomStateForTest(SeedRand::ZEROS);
4143
const CKey key = [&] {
4244
CKey k;
4345
k.Set(buffer.begin(), buffer.end(), true);

src/test/fuzz/mini_miner.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void initialize_miner()
3434
// Test that the MiniMiner can run with various outpoints and feerates.
3535
FUZZ_TARGET(mini_miner, .init = initialize_miner)
3636
{
37+
SeedRandomStateForTest(SeedRand::ZEROS);
3738
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
3839
bilingual_str error;
3940
CTxMemPool pool{CTxMemPool::Options{}, error};
@@ -112,6 +113,7 @@ FUZZ_TARGET(mini_miner, .init = initialize_miner)
112113
// Test that MiniMiner and BlockAssembler build the same block given the same transactions and constraints.
113114
FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
114115
{
116+
SeedRandomStateForTest(SeedRand::ZEROS);
115117
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
116118
bilingual_str error;
117119
CTxMemPool pool{CTxMemPool::Options{}, error};

src/test/fuzz/netaddress.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
#include <test/fuzz/FuzzedDataProvider.h>
77
#include <test/fuzz/fuzz.h>
88
#include <test/fuzz/util/net.h>
9+
#include <test/util/random.h>
910

1011
#include <cassert>
1112
#include <cstdint>
1213
#include <vector>
1314

1415
FUZZ_TARGET(netaddress)
1516
{
17+
SeedRandomStateForTest(SeedRand::ZEROS);
1618
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
1719

1820
const CNetAddr net_addr = ConsumeNetAddr(fuzzed_data_provider);

src/test/fuzz/p2p_handshake.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void initialize()
3939

4040
FUZZ_TARGET(p2p_handshake, .init = ::initialize)
4141
{
42+
SeedRandomStateForTest(SeedRand::ZEROS);
4243
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
4344

4445
ConnmanTestMsg& connman = static_cast<ConnmanTestMsg&>(*g_setup->m_node.connman);

src/test/fuzz/p2p_headers_presync.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void initialize()
153153

154154
FUZZ_TARGET(p2p_headers_presync, .init = initialize)
155155
{
156+
SeedRandomStateForTest(SeedRand::ZEROS);
156157
ChainstateManager& chainman = *g_testing_setup->m_node.chainman;
157158

158159
LOCK(NetEventsInterface::g_msgproc_mutex);

src/test/fuzz/package_eval.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ std::optional<COutPoint> GetChildEvictingPrevout(const CTxMemPool& tx_pool)
188188

189189
FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
190190
{
191+
SeedRandomStateForTest(SeedRand::ZEROS);
191192
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
192193
const auto& node = g_setup->m_node;
193194
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
@@ -342,6 +343,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
342343

343344
FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
344345
{
346+
SeedRandomStateForTest(SeedRand::ZEROS);
345347
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
346348
const auto& node = g_setup->m_node;
347349
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};

src/test/fuzz/partially_downloaded_block.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ PartiallyDownloadedBlock::CheckBlockFn FuzzedCheckBlock(std::optional<BlockValid
4444

4545
FUZZ_TARGET(partially_downloaded_block, .init = initialize_pdb)
4646
{
47+
SeedRandomStateForTest(SeedRand::ZEROS);
4748
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
4849

4950
auto block{ConsumeDeserializable<CBlock>(fuzzed_data_provider, TX_WITH_WITNESS)};

src/test/fuzz/process_message.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void initialize_process_message()
5252

5353
FUZZ_TARGET(process_message, .init = initialize_process_message)
5454
{
55+
SeedRandomStateForTest(SeedRand::ZEROS);
5556
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
5657

5758
ConnmanTestMsg& connman = *static_cast<ConnmanTestMsg*>(g_setup->m_node.connman.get());

src/test/fuzz/process_messages.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void initialize_process_messages()
4242

4343
FUZZ_TARGET(process_messages, .init = initialize_process_messages)
4444
{
45+
SeedRandomStateForTest(SeedRand::ZEROS);
4546
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
4647

4748
ConnmanTestMsg& connman = *static_cast<ConnmanTestMsg*>(g_setup->m_node.connman.get());

src/test/fuzz/psbt.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <test/fuzz/FuzzedDataProvider.h>
6-
#include <test/fuzz/fuzz.h>
7-
85
#include <node/psbt.h>
96
#include <psbt.h>
107
#include <pubkey.h>
118
#include <script/script.h>
129
#include <streams.h>
10+
#include <test/fuzz/FuzzedDataProvider.h>
11+
#include <test/fuzz/fuzz.h>
12+
#include <test/util/random.h>
1313
#include <util/check.h>
1414

1515
#include <cstdint>
@@ -23,6 +23,7 @@ using node::PSBTInputAnalysis;
2323

2424
FUZZ_TARGET(psbt)
2525
{
26+
SeedRandomStateForTest(SeedRand::ZEROS);
2627
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
2728
PartiallySignedTransaction psbt_mut;
2829
std::string error;

src/test/fuzz/rbf.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void initialize_package_rbf()
5151

5252
FUZZ_TARGET(rbf, .init = initialize_rbf)
5353
{
54+
SeedRandomStateForTest(SeedRand::ZEROS);
5455
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
5556
SetMockTime(ConsumeTime(fuzzed_data_provider));
5657
std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
@@ -92,6 +93,7 @@ FUZZ_TARGET(rbf, .init = initialize_rbf)
9293

9394
FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
9495
{
96+
SeedRandomStateForTest(SeedRand::ZEROS);
9597
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
9698
SetMockTime(ConsumeTime(fuzzed_data_provider));
9799

src/test/fuzz/rolling_bloom_filter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <test/fuzz/FuzzedDataProvider.h>
77
#include <test/fuzz/fuzz.h>
88
#include <test/fuzz/util.h>
9+
#include <test/util/random.h>
910
#include <uint256.h>
1011

1112
#include <cassert>
@@ -16,6 +17,7 @@
1617

1718
FUZZ_TARGET(rolling_bloom_filter)
1819
{
20+
SeedRandomStateForTest(SeedRand::ZEROS);
1921
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
2022

2123
CRollingBloomFilter rolling_bloom_filter{

src/test/fuzz/rpc.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ void initialize_rpc()
365365

366366
FUZZ_TARGET(rpc, .init = initialize_rpc)
367367
{
368+
SeedRandomStateForTest(SeedRand::ZEROS);
368369
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
369370
bool good_data{true};
370371
SetMockTime(ConsumeTime(fuzzed_data_provider));

src/test/fuzz/script_sigcache.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void initialize_script_sigcache()
2525

2626
FUZZ_TARGET(script_sigcache, .init = initialize_script_sigcache)
2727
{
28+
SeedRandomStateForTest(SeedRand::ZEROS);
2829
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
2930

3031
const auto max_sigcache_bytes{fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, DEFAULT_SIGNATURE_CACHE_BYTES)};

src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <test/fuzz/FuzzedDataProvider.h>
88
#include <test/fuzz/fuzz.h>
99
#include <test/fuzz/util.h>
10+
#include <test/util/random.h>
1011

1112
#include <cstdint>
1213
#include <vector>
@@ -16,6 +17,7 @@ int ecdsa_signature_parse_der_lax(secp256k1_ecdsa_signature* sig, const unsigned
1617

1718
FUZZ_TARGET(secp256k1_ecdsa_signature_parse_der_lax)
1819
{
20+
SeedRandomStateForTest(SeedRand::ZEROS);
1921
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
2022
const std::vector<uint8_t> signature_bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
2123
if (signature_bytes.data() == nullptr) {

src/test/fuzz/transaction.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <primitives/transaction.h>
1515
#include <streams.h>
1616
#include <test/fuzz/fuzz.h>
17+
#include <test/util/random.h>
1718
#include <univalue.h>
1819
#include <util/chaintype.h>
1920
#include <util/rbf.h>
@@ -28,6 +29,7 @@ void initialize_transaction()
2829

2930
FUZZ_TARGET(transaction, .init = initialize_transaction)
3031
{
32+
SeedRandomStateForTest(SeedRand::ZEROS);
3133
DataStream ds{buffer};
3234
bool valid_tx = true;
3335
const CTransaction tx = [&] {

src/test/fuzz/tx_pool.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void CheckATMPInvariants(const MempoolAcceptResult& res, bool txid_in_mempool, b
187187

188188
FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
189189
{
190+
SeedRandomStateForTest(SeedRand::ZEROS);
190191
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
191192
const auto& node = g_setup->m_node;
192193
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
@@ -365,6 +366,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
365366

366367
FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
367368
{
369+
SeedRandomStateForTest(SeedRand::ZEROS);
368370
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
369371
const auto& node = g_setup->m_node;
370372
auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};

src/test/fuzz/txdownloadman.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ void CheckPackageToValidate(const node::PackageToValidate& package_to_validate,
165165

166166
FUZZ_TARGET(txdownloadman, .init = initialize)
167167
{
168+
SeedRandomStateForTest(SeedRand::ZEROS);
168169
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
169170

170171
// Initialize txdownloadman
@@ -294,6 +295,7 @@ static void CheckInvariants(const node::TxDownloadManagerImpl& txdownload_impl,
294295

295296
FUZZ_TARGET(txdownloadman_impl, .init = initialize)
296297
{
298+
SeedRandomStateForTest(SeedRand::ZEROS);
297299
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
298300

299301
// Initialize a TxDownloadManagerImpl

src/test/fuzz/utxo_snapshot.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void initialize_chain()
7070
template <bool INVALID>
7171
void utxo_snapshot_fuzz(FuzzBufferType buffer)
7272
{
73+
SeedRandomStateForTest(SeedRand::ZEROS);
7374
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
7475
auto& setup{*g_setup};
7576
bool dirty_chainman{false}; // Re-use the global chainman, but reset it when it is dirty

src/test/fuzz/utxo_total_supply.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ FUZZ_TARGET(utxo_total_supply)
2626
.extra_args = {"-testactivationheight=bip34@2"},
2727
},
2828
};
29+
SeedRandomStateForTest(SeedRand::ZEROS); // Can not be done before test_setup
2930
// Create chainstate
3031
test_setup.LoadVerifyActivateChainstate();
3132
auto& node{test_setup.m_node};

src/test/fuzz/validation_load_mempool.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void initialize_validation_load_mempool()
3838

3939
FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
4040
{
41+
SeedRandomStateForTest(SeedRand::ZEROS);
4142
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
4243
SetMockTime(ConsumeTime(fuzzed_data_provider));
4344
FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};

src/wallet/test/fuzz/coinselection.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ FUZZ_TARGET(coin_grinder_is_optimal)
218218

219219
FUZZ_TARGET(coinselection)
220220
{
221+
SeedRandomStateForTest(SeedRand::ZEROS);
221222
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
222223
std::vector<COutput> utxo_pool;
223224

src/wallet/test/fuzz/notifications.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void initialize_setup()
5656

5757
FUZZ_TARGET(wallet_notifications, .init = initialize_setup)
5858
{
59+
SeedRandomStateForTest(SeedRand::ZEROS);
5960
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
6061
// The total amount, to be distributed to the wallets a and b in txs
6162
// without fee. Thus, the balance of the wallets should always equal the

src/wallet/test/fuzz/scriptpubkeyman.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static DescriptorScriptPubKeyMan* CreateDescriptor(WalletDescriptor& wallet_desc
8585

8686
FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm)
8787
{
88+
SeedRandomStateForTest(SeedRand::ZEROS);
8889
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
8990
const auto& node{g_setup->m_node};
9091
Chainstate& chainstate{node.chainman->ActiveChainstate()};

0 commit comments

Comments
 (0)