tests: make fuzz tests (mostly) deterministic with fixed seed

This commit is contained in:
Pieter Wuille
2024-03-15 14:32:20 -04:00
parent 2c91330dd6
commit 97e16f5704
2 changed files with 10 additions and 1 deletions

View File

@@ -102,6 +102,12 @@ void ResetCoverageCounters() {}
void initialize()
{
// By default, make the RNG deterministic with a fixed seed. This will affect all
// randomness during the fuzz test, except:
// - GetStrongRandBytes(), which is used for the creation of private key material.
// - Creating a BasicTestingSetup or derived class will switch to a random seed.
SeedRandomForTest(SeedRand::ZEROS);
// Terminate immediately if a fuzzing harness ever tries to create a socket.
// Individual tests can override this by pointing CreateSock to a mocked alternative.
CreateSock = [](int, int, int) -> std::unique_ptr<Sock> { std::terminate(); };