diff --git a/src/test/fuzz/cmpctblock.cpp b/src/test/fuzz/cmpctblock.cpp index e14930a048b..3e4268cb658 100644 --- a/src/test/fuzz/cmpctblock.cpp +++ b/src/test/fuzz/cmpctblock.cpp @@ -379,6 +379,29 @@ FUZZ_TARGET(cmpctblock, .init = initialize_cmpctblock) CBlockHeaderAndShortTxIDs base_cmpctblock = cmpctblock; net_msg = NetMsg::Make(NetMsgType::CMPCTBLOCK, base_cmpctblock); }, + [&]() { + // Send a blocktxn message for an existing block (if one exists). + size_t num_blocks = info.size(); + if (num_blocks == 0) { + sent_net_msg = false; + return; + } + + // Fetch an existing block and randomly choose transactions to send over. + size_t index = fuzzed_data_provider.ConsumeIntegralInRange(0, num_blocks - 1); + const BlockInfo& block_info = info[index]; + BlockTransactions block_txn; + block_txn.blockhash = block_info.hash; + std::shared_ptr cblock = block_info.block; + + for (size_t i = 0; i < cblock->vtx.size(); i++) { + if (fuzzed_data_provider.ConsumeBool()) continue; + + block_txn.txn.push_back(cblock->vtx[i]); + } + + net_msg = NetMsg::Make(NetMsgType::BLOCKTXN, block_txn); + }, [&]() { // Send a headers message for an existing block (if one exists). size_t num_blocks = info.size();