Skip to content

Commit 741589c

Browse files
committed
Merge rust-bitcoin#2828: fuzz: add more coverage for deserialize_block
ee30eaa fuzz: add more coverage for `deserialize_block` (Bruno Garcia) Pull request description: This PR adds more coverage for the `deserialize_block` target. First, it serializes the block and compares with the data provided and then call some block functions to ensure they run without any issue. ACKs for top commit: apoelstra: ACK ee30eaa Thanks! Tree-SHA512: db6c7befa7b429267e9b28fb7910d2b9e8d462e22c791b544b1aa528c7ba4f8e1cd32e1276c67d3da1f97ce484e7ed19ec20b10d2030f2977fd8f855cf510ffe
2 parents 4ce7ee1 + ee30eaa commit 741589c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

fuzz/fuzz_targets/bitcoin/deserialize_block.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
use honggfuzz::fuzz;
22

33
fn do_test(data: &[u8]) {
4-
let _: Result<bitcoin::blockdata::block::Block, _> =
4+
let block_result: Result<bitcoin::blockdata::block::Block, _> =
55
bitcoin::consensus::encode::deserialize(data);
6+
7+
match block_result {
8+
Err(_) => {}
9+
Ok(block) => {
10+
let ser = bitcoin::consensus::encode::serialize(&block);
11+
assert_eq!(&ser[..], data);
12+
let _ = block.bip34_block_height();
13+
block.block_hash();
14+
block.check_merkle_root();
15+
block.check_witness_commitment();
16+
block.weight();
17+
block.witness_root();
18+
}
19+
}
620
}
721

822
fn main() {

0 commit comments

Comments
 (0)