mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 11:13:23 -03:00
fuzz: Avoid time-based "non-determinism" in fuzzing harnesses by using mocked GetTime()
This commit is contained in:
parent
dfd0b70088
commit
8c09c0c1d1
4 changed files with 4 additions and 1 deletions
|
@ -32,6 +32,7 @@ void initialize()
|
||||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
const fs::path banlist_file = GetDataDir() / "fuzzed_banlist.dat";
|
const fs::path banlist_file = GetDataDir() / "fuzzed_banlist.dat";
|
||||||
fs::remove(banlist_file);
|
fs::remove(banlist_file);
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ void initialize()
|
||||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
CConnman connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeBool()};
|
CConnman connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeBool()};
|
||||||
CAddress random_address;
|
CAddress random_address;
|
||||||
CNetAddr random_netaddr;
|
CNetAddr random_netaddr;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void initialize()
|
||||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||||
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
const std::optional<CAddress> address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
|
const std::optional<CAddress> address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
|
||||||
if (!address) {
|
if (!address) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||||
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
||||||
if (!mtx) {
|
if (!mtx) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue