Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-fullblocktest.py
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | def next_block(self, number, spend=None, script=CScript([OP_TRUE]), block_size=0, extra_sigops=0): | ||||
[b'\x00' * script_pad_len] + [OP_CHECKSIG] * tx_sigops) | [b'\x00' * script_pad_len] + [OP_CHECKSIG] * tx_sigops) | ||||
tx.vout.append(CTxOut(0, script_output)) | tx.vout.append(CTxOut(0, script_output)) | ||||
# Add the tx to the list of transactions to be included | # Add the tx to the list of transactions to be included | ||||
# in the block. | # in the block. | ||||
self.add_transactions_to_block(block, [tx]) | self.add_transactions_to_block(block, [tx]) | ||||
current_block_size += len(tx.serialize()) | current_block_size += len(tx.serialize()) | ||||
make_conform_to_ctor(block) | |||||
deadalnix: Put it just before the merkle root hash computation. | |||||
# Now that we added a bunch of transaction, we need to recompute | # Now that we added a bunch of transaction, we need to recompute | ||||
# the merkle root. | # the merkle root. | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
# Check that the block size is what's expected | # Check that the block size is what's expected | ||||
if block_size > 0: | if block_size > 0: | ||||
assert_equal(len(block.serialize()), block_size) | assert_equal(len(block.serialize()), block_size) | ||||
Show All 34 Lines | def get_tests(self): | ||||
def tip(number): | def tip(number): | ||||
self.tip = self.blocks[number] | self.tip = self.blocks[number] | ||||
# adds transactions to the block and updates state | # adds transactions to the block and updates state | ||||
def update_block(block_number, new_transactions): | def update_block(block_number, new_transactions): | ||||
block = self.blocks[block_number] | block = self.blocks[block_number] | ||||
self.add_transactions_to_block(block, new_transactions) | self.add_transactions_to_block(block, new_transactions) | ||||
old_sha256 = block.sha256 | old_sha256 = block.sha256 | ||||
make_conform_to_ctor(block) | |||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.solve() | block.solve() | ||||
# Update the internal state just like in next_block | # Update the internal state just like in next_block | ||||
self.tip = block | self.tip = block | ||||
if block.sha256 != old_sha256: | if block.sha256 != old_sha256: | ||||
self.block_heights[ | self.block_heights[ | ||||
block.sha256] = self.block_heights[old_sha256] | block.sha256] = self.block_heights[old_sha256] | ||||
del self.block_heights[old_sha256] | del self.block_heights[old_sha256] | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |
Put it just before the merkle root hash computation.