def test_invalid_tx_in_compactblock(self, test_node, use_segwit=True):
    node = self.nodes[0]
    assert len(self.utxos)
    utxo = self.utxos[0]
    block = self.build_block_with_transactions(node, utxo, 5)
    del block.vtx[3]
    block.hashMerkleRoot = block.calc_merkle_root()
    if use_segwit:
        add_witness_commitment(block)
        block.vtx[0].wit.vtxinwit = []
    block.solve()
    comp_block = HeaderAndShortIDs()
    comp_block.initialize_from_block(block, prefill_list=[0, 1, 2, 3, 4], use_witness=use_segwit)
    msg = msg_cmpctblock(comp_block.to_p2p())
    test_node.send_and_ping(msg)
    assert (int(node.getbestblockhash(), 16) is not block.sha256)
    test_node.sync_with_ping()
def test_invalid_tx_in_compactblock(self, test_node, use_segwit=True):
    node = self.nodes[0]
    assert len(self.utxos)
    utxo = self.utxos[0]
    block = self.build_block_with_transactions(node, utxo, 5)
    del block.vtx[3]
    block.hashMerkleRoot = block.calc_merkle_root()
    if use_segwit:
        add_witness_commitment(block)
        block.vtx[0].wit.vtxinwit = []
    block.solve()
    comp_block = HeaderAndShortIDs()
    comp_block.initialize_from_block(block, prefill_list=[0, 1, 2, 3, 4], use_witness=use_segwit)
    msg = msg_cmpctblock(comp_block.to_p2p())
    test_node.send_and_ping(msg)
    assert (int(node.getbestblockhash(), 16) is not block.sha256)
    test_node.sync_with_ping()