Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
fuzz
util
threadinterrupt.cpp
Go to the documentation of this file.
1
// Copyright (c) 2024-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
test/fuzz/util.h
>
6
#include <
test/fuzz/util/threadinterrupt.h
>
7
8
FuzzedThreadInterrupt::FuzzedThreadInterrupt
(
FuzzedDataProvider
& fuzzed_data_provider)
9
:
m_fuzzed_data_provider
{fuzzed_data_provider}
10
{
11
}
12
13
bool
FuzzedThreadInterrupt::interrupted
()
const
14
{
15
return
m_fuzzed_data_provider
.ConsumeBool();
16
}
17
18
bool
FuzzedThreadInterrupt::sleep_for
(Clock::duration)
19
{
20
SetMockTime
(
ConsumeTime
(
m_fuzzed_data_provider
));
// Time could go backwards.
21
return
m_fuzzed_data_provider
.ConsumeBool();
22
}
FuzzedDataProvider
Definition
FuzzedDataProvider.h:32
FuzzedThreadInterrupt::interrupted
virtual bool interrupted() const override
Return true if operator()() has been called.
Definition
threadinterrupt.cpp:13
FuzzedThreadInterrupt::sleep_for
virtual bool sleep_for(Clock::duration) override
Sleep for the given duration.
Definition
threadinterrupt.cpp:18
FuzzedThreadInterrupt::FuzzedThreadInterrupt
FuzzedThreadInterrupt(FuzzedDataProvider &fuzzed_data_provider)
Definition
threadinterrupt.cpp:8
FuzzedThreadInterrupt::m_fuzzed_data_provider
FuzzedDataProvider & m_fuzzed_data_provider
Definition
threadinterrupt.h:25
threadinterrupt.h
ConsumeTime
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
Definition
util.cpp:34
util.h
SetMockTime
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition
time.cpp:44
Generated on
for Bitcoin Core by
1.17.0