From 40add915be5c5d204d85474a2704362cb635ef6d Mon Sep 17 00:00:00 2001 From: Eugene Siegel Date: Wed, 26 Aug 2026 17:18:38 +0100 Subject: [PATCH 1/2] test: Add reset to CuckooCache Add a method that clears and resets CuckooCache, intended for use in tests only. Without this, fuzz tests may reuse the cache across iterations, resulting in instability. --- src/cuckoocache.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cuckoocache.h b/src/cuckoocache.h index e25f691341f..a064607537c 100644 --- a/src/cuckoocache.h +++ b/src/cuckoocache.h @@ -329,7 +329,7 @@ public: /** setup initializes the container to store no more than new_size * elements and no less than 2 elements. * - * setup should only be called once. + * setup should only be called once. TestOnlyReset() is the exception. * * @param new_size the desired number of elements to store * @returns the maximum number of elements storable @@ -483,6 +483,14 @@ public: } return false; } + + /** Empty the cache and re-run setup(). */ + void TestOnlyReset() + { + table.clear(); + epoch_flags.clear(); + setup(0); + } }; } // namespace CuckooCache From 2777300c68f575565dabdcef4d0498ebc91a401e Mon Sep 17 00:00:00 2001 From: Robin David Date: Tue, 12 Aug 2025 16:41:40 +0200 Subject: [PATCH 2/2] fuzz: Implement connect_block harness Co-authored-by: marcofleon --- src/test/fuzz/CMakeLists.txt | 1 + src/test/fuzz/connect_block.cpp | 480 ++++++++++++++++++++++++++++++++ 2 files changed, 481 insertions(+) create mode 100644 src/test/fuzz/connect_block.cpp diff --git a/src/test/fuzz/CMakeLists.txt b/src/test/fuzz/CMakeLists.txt index 7888f149008..b2e88303fb6 100644 --- a/src/test/fuzz/CMakeLists.txt +++ b/src/test/fuzz/CMakeLists.txt @@ -29,6 +29,7 @@ add_executable(fuzz cmpctblock.cpp coins_view.cpp coinscache_sim.cpp + connect_block.cpp connman.cpp crypto.cpp crypto_aes256.cpp diff --git a/src/test/fuzz/connect_block.cpp b/src/test/fuzz/connect_block.cpp new file mode 100644 index 00000000000..7c70dce173c --- /dev/null +++ b/src/test/fuzz/connect_block.cpp @@ -0,0 +1,480 @@ +// Copyright (c) 2026-present The Bitcoin Core developers +// 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 +#include +#include +#include +#include