Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-mempool-coherence-on-activations.py
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# save the current tip so it can be spent by a later block | # save the current tip so it can be spent by a later block | ||||
def save_spendable_output(): | def save_spendable_output(): | ||||
spendable_outputs.append(self.tip) | spendable_outputs.append(self.tip) | ||||
# get an output that we previously marked as spendable | # get an output that we previously marked as spendable | ||||
def get_spendable_output(): | def get_spendable_output(): | ||||
return PreviousSpendableOutput(spendable_outputs.pop(0).vtx[0], 0) | return PreviousSpendableOutput(spendable_outputs.pop(0).vtx[0], 0) | ||||
# move the tip back to a previous block | |||||
def tip(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] | ||||
block.vtx.extend(new_transactions) | block.vtx.extend(new_transactions) | ||||
old_sha256 = block.sha256 | old_sha256 = block.sha256 | ||||
make_conform_to_ctor(block) | make_conform_to_ctor(block) | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.solve() | block.solve() | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# after the fork. We will test such a case here and make sure that | # after the fork. We will test such a case here and make sure that | ||||
# post-fork-only transactions are not unnecessarily discarded from | # post-fork-only transactions are not unnecessarily discarded from | ||||
# the mempool in such a reorg. Pre-fork-only transactions however can | # the mempool in such a reorg. Pre-fork-only transactions however can | ||||
# get lost. | # get lost. | ||||
# Set up a longer competing chain that doesn't confirm any of our txns. | # Set up a longer competing chain that doesn't confirm any of our txns. | ||||
# This starts after 5204, so it contains neither the forkblockid nor | # This starts after 5204, so it contains neither the forkblockid nor | ||||
# the postforkblockid from above. | # the postforkblockid from above. | ||||
tip(5204) | self.tip = self.blocks[5204] | ||||
reorg_blocks = [] | reorg_blocks = [] | ||||
for i in range(3): | for i in range(3): | ||||
reorg_blocks.append(block(5900 + i)) | reorg_blocks.append(block(5900 + i)) | ||||
# Perform the reorg | # Perform the reorg | ||||
node.p2p.send_blocks_and_test(reorg_blocks, node) | node.p2p.send_blocks_and_test(reorg_blocks, node) | ||||
# reorg finishes after the fork | # reorg finishes after the fork | ||||
assert_equal( | assert_equal( | ||||
Show All 13 Lines |