diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-06-02 19:02:26 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-07-15 11:41:21 +0000 |
commit | e48094a506ad031d211b9dfe7639d8b3a2239788 (patch) | |
tree | 59463e3989b19dc2199b8238c28c73ac2eff0901 | |
parent | 9dbcd6854ca05a9bd1e9a5e1222dac1758048231 (diff) | |
download | bitcoin-e48094a506ad031d211b9dfe7639d8b3a2239788.tar.xz |
tests: Add FuzzedAutoFileProvider which provides a CAutoFile interface to FuzzedDataProvider
-rw-r--r-- | src/test/fuzz/util.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index dffef13cc9..9fe92c7f84 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -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 |