diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -96,13 +96,16 @@ self.nodes[0].setexcessiveblock(self.excessive_block_size) self.test.run() + def add_transactions_to_block(self, block, tx_list): + [tx.rehash() for tx in tx_list] + block.vtx.extend(tx_list) + # this is a little handier to use than the version in blocktools.py def create_tx(self, spend_tx, n, value, script=CScript([OP_TRUE])): tx = create_transaction(spend_tx, n, b"", value, script) return tx def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0, extra_txns=0): - assert number not in self.blocks if self.tip == None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 @@ -154,11 +157,11 @@ CTxOut(0, CScript([random.randint(0, 256), OP_RETURN]))) # Add the transaction to the block - block.vtx.append(tx) + self.add_transactions_to_block(block, [tx]) # Add transaction until we reach the expected transaction count - block.vtx.extend([get_base_transaction() - for _ in range(extra_txns)]) + for _ in range(extra_txns): + self.add_transactions_to_block(block, [get_base_transaction()]) # If we have a block size requirement, just fill # the block until we get there @@ -187,7 +190,7 @@ # Add the tx to the list of transactions to be included # in the block. - block.vtx.append(tx) + self.add_transactions_to_block(block, [tx]) current_block_size += len(tx.serialize()) # Now that we added a bunch of transaction, we need to recompute @@ -203,6 +206,7 @@ block.solve() self.tip = block self.block_heights[block.sha256] = height + assert number not in self.blocks self.blocks[number] = block return block