mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
[checkqueue] support user-defined return type through std::optional
The check type function now needs to return a std::optional<R> for some type R, and the check queue overall will return std::nullopt if all individual checks return that, or one of the non-nullopt values if there is at least one. For most tests, we use R=int, but for the actual validation code, we make it return the ScriptError.
This commit is contained in:
@@ -19,9 +19,10 @@ struct DumbCheck {
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()() const
|
||||
std::optional<int> operator()() const
|
||||
{
|
||||
return result;
|
||||
if (result) return std::nullopt;
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
@@ -45,7 +46,7 @@ FUZZ_TARGET(checkqueue)
|
||||
check_queue_1.Add(std::move(checks_1));
|
||||
}
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
(void)check_queue_1.Wait();
|
||||
(void)check_queue_1.Complete();
|
||||
}
|
||||
|
||||
CCheckQueueControl<DumbCheck> check_queue_control{&check_queue_2};
|
||||
@@ -53,6 +54,6 @@ FUZZ_TARGET(checkqueue)
|
||||
check_queue_control.Add(std::move(checks_2));
|
||||
}
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
(void)check_queue_control.Wait();
|
||||
(void)check_queue_control.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user