From 40add915be5c5d204d85474a2704362cb635ef6d Mon Sep 17 00:00:00 2001 From: Eugene Siegel Date: Wed, 26 Aug 2026 17:18:38 +0100 Subject: [PATCH] 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