diff options
author | dergoegge <n.goeggi@gmail.com> | 2023-12-08 13:14:46 +0000 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2023-12-08 13:14:46 +0000 |
commit | 15f5a0d0c8ce6b306cdeba6a4777334b848a76aa (patch) | |
tree | 7d536562fe217da051c5ec1b250feded0d74485c /src/test | |
parent | dce1dfbc47050404bcf3ce2461e8baff0b088ffb (diff) |
fuzz: Improve fuzzing stability for txorphan harness
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/txorphan.cpp | 3 | ||||
-rw-r--r-- | src/test/orphanage_tests.cpp | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp index 714b321bce..5423ba8920 100644 --- a/src/test/fuzz/txorphan.cpp +++ b/src/test/fuzz/txorphan.cpp @@ -33,6 +33,7 @@ void initialize_orphanage() FUZZ_TARGET(txorphan, .init = initialize_orphanage) { FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); + FastRandomContext limit_orphans_rng{/*fDeterministic=*/true}; SetMockTime(ConsumeTime(fuzzed_data_provider)); TxOrphanage orphanage; @@ -132,7 +133,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage) // test mocktime and expiry SetMockTime(ConsumeTime(fuzzed_data_provider)); auto limit = fuzzed_data_provider.ConsumeIntegral<unsigned int>(); - orphanage.LimitOrphans(limit); + orphanage.LimitOrphans(limit, limit_orphans_rng); Assert(orphanage.Size() <= limit); }); } diff --git a/src/test/orphanage_tests.cpp b/src/test/orphanage_tests.cpp index bf465c0c64..4231fcc909 100644 --- a/src/test/orphanage_tests.cpp +++ b/src/test/orphanage_tests.cpp @@ -129,11 +129,12 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans) } // Test LimitOrphanTxSize() function: - orphanage.LimitOrphans(40); + FastRandomContext rng{/*fDeterministic=*/true}; + orphanage.LimitOrphans(40, rng); BOOST_CHECK(orphanage.CountOrphans() <= 40); - orphanage.LimitOrphans(10); + orphanage.LimitOrphans(10, rng); BOOST_CHECK(orphanage.CountOrphans() <= 10); - orphanage.LimitOrphans(0); + orphanage.LimitOrphans(0, rng); BOOST_CHECK(orphanage.CountOrphans() == 0); } |