mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
tests: Pass fuzzing inputs as constant references
This commit is contained in:
parent
7b701fef58
commit
ffa2221256
4 changed files with 5 additions and 4 deletions
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
|
||||||
void test_one_input(std::vector<uint8_t> buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -30,7 +30,8 @@ static void initialize()
|
||||||
// This function is used by libFuzzer
|
// This function is used by libFuzzer
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
test_one_input(std::vector<uint8_t>(data, data + size));
|
const std::vector<uint8_t> input(data, data + size);
|
||||||
|
test_one_input(input);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
void test_one_input(std::vector<uint8_t> buffer);
|
void test_one_input(const std::vector<uint8_t>& buffer);
|
||||||
|
|
||||||
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
|
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
/** Flags that are not forbidden by an assert */
|
/** Flags that are not forbidden by an assert */
|
||||||
static bool IsValidFlagCombination(unsigned flags);
|
static bool IsValidFlagCombination(unsigned flags);
|
||||||
|
|
||||||
void test_one_input(std::vector<uint8_t> buffer)
|
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
{
|
{
|
||||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue