/root/bitcoin/src/test/fuzz/protocol.cpp
Line | Count | Source |
1 | | // Copyright (c) 2020-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 <protocol.h> |
6 | | #include <test/fuzz/FuzzedDataProvider.h> |
7 | | #include <test/fuzz/fuzz.h> |
8 | | #include <test/fuzz/util.h> |
9 | | |
10 | | #include <cstdint> |
11 | | #include <optional> |
12 | | #include <stdexcept> |
13 | | #include <vector> |
14 | | |
15 | | FUZZ_TARGET(protocol) |
16 | 63 | { |
17 | 63 | FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); |
18 | 63 | const std::optional<CInv> inv = ConsumeDeserializable<CInv>(fuzzed_data_provider); |
19 | 63 | if (!inv) { Branch (19:9): [True: 28, False: 35]
|
20 | 28 | return; |
21 | 28 | } |
22 | 35 | try { |
23 | 35 | (void)inv->GetMessageType(); |
24 | 35 | } catch (const std::out_of_range&) { |
25 | 8 | } |
26 | 35 | (void)inv->ToString(); |
27 | 35 | const std::optional<CInv> another_inv = ConsumeDeserializable<CInv>(fuzzed_data_provider); |
28 | 35 | if (!another_inv) { Branch (28:9): [True: 21, False: 14]
|
29 | 21 | return; |
30 | 21 | } |
31 | 14 | (void)(*inv < *another_inv); |
32 | 14 | } |