mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
tests: Add FuzzedAutoFileProvider which provides a CAutoFile interface to FuzzedDataProvider
This commit is contained in:
parent
9dbcd6854c
commit
e48094a506
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue