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 @@ -19,6 +19,7 @@ from test_framework.script import * from test_framework.cdefs import (ONE_MEGABYTE, LEGACY_MAX_BLOCK_SIZE, MAX_BLOCK_SIGOPS_PER_MB, MAX_TX_SIGOPS_COUNT) +from test_framework.txtools import pad_tx from collections import deque @@ -97,8 +98,12 @@ self.test.run() def add_transactions_to_block(self, block, tx_list): - [tx.rehash() for tx in tx_list] - block.vtx.extend(tx_list) + for tx in tx_list: + pad_tx(tx) + tx.rehash() + tx_list = block.vtx[1:] + tx_list + block.vtx = [block.vtx[0]] + \ + sorted(tx_list, key=lambda tx: tx.get_id()) # 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])): @@ -193,6 +198,10 @@ self.add_transactions_to_block(block, [tx]) current_block_size += len(tx.serialize()) + # Order transactions canonically + block.vtx = [block.vtx[0]] + \ + sorted(block.vtx[1:], key=lambda tx: tx.get_id()) + # Now that we added a bunch of transaction, we need to recompute # the merkle root. block.hashMerkleRoot = block.calc_merkle_root()