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

Function DeserializeAndCheckBlockTest

src/bench/checkblock.cpp:31–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
32{
33 CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
34 std::byte a{0};
35 stream.write({&a, 1}); // Prevent compaction
36
37 ArgsManager bench_args;
38 const auto chainParams = CreateChainParams(bench_args, CBaseChainParams::MAIN);
39
40 bench.unit("block").run([&] {
41 CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
42 stream >> block;
43 bool rewound = stream.Rewind(benchmark::data::block413567.size());
44 assert(rewound);
45
46 BlockValidationState validationState;
47 bool checked = CheckBlock(block, validationState, chainParams->GetConsensus());
48 assert(checked);
49 });
50}
51
52BENCHMARK(DeserializeBlockTest);
53BENCHMARK(DeserializeAndCheckBlockTest);

Callers

nothing calls this directly

Calls 6

CreateChainParamsFunction · 0.85
CheckBlockFunction · 0.85
writeMethod · 0.45
runMethod · 0.45
RewindMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected