MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/block_header.cpp:17–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <vector>
16
17FUZZ_TARGET(block_header)
18{
19 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
20 const std::optional<CBlockHeader> block_header = ConsumeDeserializable<CBlockHeader>(fuzzed_data_provider);
21 if (!block_header) {
22 return;
23 }
24 {
25 const uint256 hash = block_header->GetHash();
26 static const uint256 u256_max(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
27 assert(hash != u256_max);
28 assert(block_header->GetBlockTime() == block_header->nTime);
29 assert(block_header->IsNull() == (block_header->nBits == 0));
30 }
31 {
32 CBlockHeader mut_block_header = *block_header;
33 mut_block_header.SetNull();
34 assert(mut_block_header.IsNull());
35 CBlock block{*block_header};
36 assert(block.GetBlockHeader().GetHash() == block_header->GetHash());
37 (void)block.ToString();
38 block.SetNull();
39 assert(block.GetBlockHeader().GetHash() == mut_block_header.GetHash());
40 }
41 {
42 std::optional<CBlockLocator> block_locator = ConsumeDeserializable<CBlockLocator>(fuzzed_data_provider);
43 if (block_locator) {
44 (void)block_locator->IsNull();
45 block_locator->SetNull();
46 assert(block_locator->IsNull());
47 }
48 }
49}

Callers

nothing calls this directly

Calls 9

uint256SFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
GetHashMethod · 0.45
GetBlockTimeMethod · 0.45
IsNullMethod · 0.45
SetNullMethod · 0.45
GetBlockHeaderMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected