mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +02:00
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.
This commit is contained in:
committed by
marcofleon
parent
67efced1fc
commit
40add915be
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user