From fa7809aeab838752af94c52977936a8c6555d315 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 13 Dec 2024 14:22:55 +0100 Subject: [PATCH 1/3] fuzz: Add missing SeedRandomStateForTest(SeedRand::ZEROS) --- src/test/fuzz/addrman.cpp | 3 +++ src/test/fuzz/banman.cpp | 1 + src/test/fuzz/blockfilter.cpp | 2 ++ src/test/fuzz/connman.cpp | 1 + src/test/fuzz/golomb_rice.cpp | 2 ++ src/test/fuzz/headerssync.cpp | 1 + src/test/fuzz/i2p.cpp | 1 + src/test/fuzz/key.cpp | 2 ++ src/test/fuzz/mini_miner.cpp | 2 ++ src/test/fuzz/netaddress.cpp | 2 ++ src/test/fuzz/p2p_handshake.cpp | 1 + src/test/fuzz/p2p_headers_presync.cpp | 1 + src/test/fuzz/package_eval.cpp | 2 ++ src/test/fuzz/partially_downloaded_block.cpp | 1 + src/test/fuzz/process_message.cpp | 1 + src/test/fuzz/process_messages.cpp | 1 + src/test/fuzz/psbt.cpp | 7 ++++--- src/test/fuzz/rbf.cpp | 2 ++ src/test/fuzz/rolling_bloom_filter.cpp | 2 ++ src/test/fuzz/rpc.cpp | 1 + src/test/fuzz/script_sigcache.cpp | 1 + src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp | 2 ++ src/test/fuzz/transaction.cpp | 2 ++ src/test/fuzz/tx_pool.cpp | 2 ++ src/test/fuzz/txdownloadman.cpp | 2 ++ src/test/fuzz/utxo_snapshot.cpp | 1 + src/test/fuzz/utxo_total_supply.cpp | 1 + src/test/fuzz/validation_load_mempool.cpp | 1 + src/wallet/test/fuzz/coinselection.cpp | 1 + src/wallet/test/fuzz/notifications.cpp | 1 + src/wallet/test/fuzz/scriptpubkeyman.cpp | 1 + 31 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 53dd7215d2e..dedea850803 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -41,6 +41,7 @@ void initialize_addrman() FUZZ_TARGET(data_stream_addr_man, .init = initialize_addrman) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; DataStream data_stream = ConsumeDataStream(fuzzed_data_provider); NetGroupManager netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)}; @@ -113,6 +114,7 @@ void FillAddrman(AddrMan& addrman, FuzzedDataProvider& fuzzed_data_provider) FUZZ_TARGET(addrman, .init = initialize_addrman) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); SetMockTime(ConsumeTime(fuzzed_data_provider)); NetGroupManager netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)}; @@ -197,6 +199,7 @@ FUZZ_TARGET(addrman, .init = initialize_addrman) // Check that serialize followed by unserialize produces the same addrman. FUZZ_TARGET(addrman_serdeser, .init = initialize_addrman) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); SetMockTime(ConsumeTime(fuzzed_data_provider)); diff --git a/src/test/fuzz/banman.cpp b/src/test/fuzz/banman.cpp index 4165cc6b2cd..bbe8e12b2f9 100644 --- a/src/test/fuzz/banman.cpp +++ b/src/test/fuzz/banman.cpp @@ -42,6 +42,7 @@ static bool operator==(const CBanEntry& lhs, const CBanEntry& rhs) FUZZ_TARGET(banman, .init = initialize_banman) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; SetMockTime(ConsumeTime(fuzzed_data_provider)); fs::path banlist_file = gArgs.GetDataDirNet() / "fuzzed_banlist"; diff --git a/src/test/fuzz/blockfilter.cpp b/src/test/fuzz/blockfilter.cpp index 3adc1145151..17e99ac94d0 100644 --- a/src/test/fuzz/blockfilter.cpp +++ b/src/test/fuzz/blockfilter.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -14,6 +15,7 @@ FUZZ_TARGET(blockfilter) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); const std::optional block_filter = ConsumeDeserializable(fuzzed_data_provider); if (!block_filter) { diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp index 20a60b098f5..a62d227da8e 100644 --- a/src/test/fuzz/connman.cpp +++ b/src/test/fuzz/connman.cpp @@ -36,6 +36,7 @@ void initialize_connman() FUZZ_TARGET(connman, .init = initialize_connman) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; SetMockTime(ConsumeTime(fuzzed_data_provider)); auto netgroupman{ConsumeNetGroupManager(fuzzed_data_provider)}; diff --git a/src/test/fuzz/golomb_rice.cpp b/src/test/fuzz/golomb_rice.cpp index 92e49445ba7..066c168652b 100644 --- a/src/test/fuzz/golomb_rice.cpp +++ b/src/test/fuzz/golomb_rice.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,7 @@ std::vector BuildHashedSet(const std::unordered_set golomb_rice_data; std::vector encoded_deltas; diff --git a/src/test/fuzz/headerssync.cpp b/src/test/fuzz/headerssync.cpp index 1aa878bd6d8..8135b0d4eab 100644 --- a/src/test/fuzz/headerssync.cpp +++ b/src/test/fuzz/headerssync.cpp @@ -48,6 +48,7 @@ class FuzzedHeadersSyncState : public HeadersSyncState FUZZ_TARGET(headers_sync_state, .init = initialize_headers_sync_state_fuzz) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); auto mock_time{ConsumeTime(fuzzed_data_provider)}; diff --git a/src/test/fuzz/i2p.cpp b/src/test/fuzz/i2p.cpp index 51517187a0a..b8024f7b1c4 100644 --- a/src/test/fuzz/i2p.cpp +++ b/src/test/fuzz/i2p.cpp @@ -21,6 +21,7 @@ void initialize_i2p() FUZZ_TARGET(i2p, .init = initialize_i2p) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; SetMockTime(ConsumeTime(fuzzed_data_provider)); diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp index 82973803f84..c7ff2f3a28e 100644 --- a/src/test/fuzz/key.cpp +++ b/src/test/fuzz/key.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ void initialize_key() FUZZ_TARGET(key, .init = initialize_key) { + SeedRandomStateForTest(SeedRand::ZEROS); const CKey key = [&] { CKey k; k.Set(buffer.begin(), buffer.end(), true); diff --git a/src/test/fuzz/mini_miner.cpp b/src/test/fuzz/mini_miner.cpp index d06594d5f8d..f82d8c72f2d 100644 --- a/src/test/fuzz/mini_miner.cpp +++ b/src/test/fuzz/mini_miner.cpp @@ -34,6 +34,7 @@ void initialize_miner() // Test that the MiniMiner can run with various outpoints and feerates. FUZZ_TARGET(mini_miner, .init = initialize_miner) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; bilingual_str error; CTxMemPool pool{CTxMemPool::Options{}, error}; @@ -112,6 +113,7 @@ FUZZ_TARGET(mini_miner, .init = initialize_miner) // Test that MiniMiner and BlockAssembler build the same block given the same transactions and constraints. FUZZ_TARGET(mini_miner_selection, .init = initialize_miner) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; bilingual_str error; CTxMemPool pool{CTxMemPool::Options{}, error}; diff --git a/src/test/fuzz/netaddress.cpp b/src/test/fuzz/netaddress.cpp index 4803cdccad5..28a2026a358 100644 --- a/src/test/fuzz/netaddress.cpp +++ b/src/test/fuzz/netaddress.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -13,6 +14,7 @@ FUZZ_TARGET(netaddress) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); const CNetAddr net_addr = ConsumeNetAddr(fuzzed_data_provider); diff --git a/src/test/fuzz/p2p_handshake.cpp b/src/test/fuzz/p2p_handshake.cpp index 6c1ed11d456..d608efd87ac 100644 --- a/src/test/fuzz/p2p_handshake.cpp +++ b/src/test/fuzz/p2p_handshake.cpp @@ -39,6 +39,7 @@ void initialize() FUZZ_TARGET(p2p_handshake, .init = ::initialize) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); ConnmanTestMsg& connman = static_cast(*g_setup->m_node.connman); diff --git a/src/test/fuzz/p2p_headers_presync.cpp b/src/test/fuzz/p2p_headers_presync.cpp index 935794057d4..873eb2b1cc9 100644 --- a/src/test/fuzz/p2p_headers_presync.cpp +++ b/src/test/fuzz/p2p_headers_presync.cpp @@ -153,6 +153,7 @@ void initialize() FUZZ_TARGET(p2p_headers_presync, .init = initialize) { + SeedRandomStateForTest(SeedRand::ZEROS); ChainstateManager& chainman = *g_testing_setup->m_node.chainman; LOCK(NetEventsInterface::g_msgproc_mutex); diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp index 0373d2493fa..42bccb70d9d 100644 --- a/src/test/fuzz/package_eval.cpp +++ b/src/test/fuzz/package_eval.cpp @@ -188,6 +188,7 @@ std::optional GetChildEvictingPrevout(const CTxMemPool& tx_pool) FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); const auto& node = g_setup->m_node; auto& chainstate{static_cast(node.chainman->ActiveChainstate())}; @@ -342,6 +343,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool) FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); const auto& node = g_setup->m_node; auto& chainstate{static_cast(node.chainman->ActiveChainstate())}; diff --git a/src/test/fuzz/partially_downloaded_block.cpp b/src/test/fuzz/partially_downloaded_block.cpp index c41005eb738..8a42807be81 100644 --- a/src/test/fuzz/partially_downloaded_block.cpp +++ b/src/test/fuzz/partially_downloaded_block.cpp @@ -44,6 +44,7 @@ PartiallyDownloadedBlock::CheckBlockFn FuzzedCheckBlock(std::optional(fuzzed_data_provider, TX_WITH_WITNESS)}; diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp index 61723882080..d8558c3f2a3 100644 --- a/src/test/fuzz/process_message.cpp +++ b/src/test/fuzz/process_message.cpp @@ -52,6 +52,7 @@ void initialize_process_message() FUZZ_TARGET(process_message, .init = initialize_process_message) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); ConnmanTestMsg& connman = *static_cast(g_setup->m_node.connman.get()); diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp index 25bda09378e..a98d0ad3b49 100644 --- a/src/test/fuzz/process_messages.cpp +++ b/src/test/fuzz/process_messages.cpp @@ -42,6 +42,7 @@ void initialize_process_messages() FUZZ_TARGET(process_messages, .init = initialize_process_messages) { + SeedRandomStateForTest(SeedRand::ZEROS); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); ConnmanTestMsg& connman = *static_cast(g_setup->m_node.connman.get()); diff --git a/src/test/fuzz/psbt.cpp b/src/test/fuzz/psbt.cpp index e0692600bb2..37fa159c33c 100644 --- a/src/test/fuzz/psbt.cpp +++ b/src/test/fuzz/psbt.cpp @@ -2,14 +2,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include -#include - #include #include #include #include