Skip to content

Commit

Permalink
tests: Add FuzzedAutoFileProvider which provides a CAutoFile interfac…
Browse files Browse the repository at this point in the history
…e to FuzzedDataProvider
  • Loading branch information
practicalswift committed Jul 15, 2020
1 parent 9dbcd68 commit e48094a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/fuzz/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,25 @@ NODISCARD inline FuzzedFileProvider ConsumeFile(FuzzedDataProvider& fuzzed_data_
return {fuzzed_data_provider};
}

class FuzzedAutoFileProvider
{
FuzzedDataProvider& m_fuzzed_data_provider;
FuzzedFileProvider m_fuzzed_file_provider;

public:
FuzzedAutoFileProvider(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider{fuzzed_data_provider}, m_fuzzed_file_provider{fuzzed_data_provider}
{
}

CAutoFile open()
{
return {m_fuzzed_file_provider.open(), m_fuzzed_data_provider.ConsumeIntegral<int>(), m_fuzzed_data_provider.ConsumeIntegral<int>()};
}
};

NODISCARD inline FuzzedAutoFileProvider ConsumeAutoFile(FuzzedDataProvider& fuzzed_data_provider) noexcept
{
return {fuzzed_data_provider};
}

#endif // BITCOIN_TEST_FUZZ_UTIL_H

0 comments on commit e48094a

Please sign in to comment.