Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-parkedchain.py
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info("Test chain parking...") | self.log.info("Test chain parking...") | ||||
self.generate(node, 10, sync_fun=self.no_op) | self.generate(node, 10, sync_fun=self.no_op) | ||||
tip = node.getbestblockhash() | tip = node.getbestblockhash() | ||||
self.generate(node, 1, sync_fun=self.no_op) | self.generate(node, 1, sync_fun=self.no_op) | ||||
block_to_park = node.getbestblockhash() | block_to_park = node.getbestblockhash() | ||||
self.generate(node, 10) | self.generate(node, 10) | ||||
parked_tip = node.getbestblockhash() | parked_tip = node.getbestblockhash() | ||||
parked_height = node.getblockcount() | |||||
# Let's park the chain. | # Let's park the chain. | ||||
assert parked_tip != tip | assert parked_tip != tip | ||||
assert block_to_park != tip | assert block_to_park != tip | ||||
assert block_to_park != parked_tip | assert block_to_park != parked_tip | ||||
with node.assert_debug_log( | |||||
[ | |||||
"Warning: Large fork found", | |||||
f"lasting to height {parked_height} ({parked_tip})", | |||||
] | |||||
): | |||||
node.parkblock(block_to_park) | node.parkblock(block_to_park) | ||||
assert_equal(node.getbestblockhash(), tip) | assert_equal(node.getbestblockhash(), tip) | ||||
# When the chain is unparked, the node reorg into its original chain. | # When the chain is unparked, the node reorg into its original chain. | ||||
node.unparkblock(parked_tip) | node.unparkblock(parked_tip) | ||||
assert_equal(node.getbestblockhash(), parked_tip) | assert_equal(node.getbestblockhash(), parked_tip) | ||||
# The "Warning: Large fork found" is no longer printed on new blocks | |||||
with node.assert_debug_log( | |||||
expected_msgs=["UpdateTip: new best=", f" height={parked_height + 1}"], | |||||
unexpected_msgs=["Warning: Large fork found"], | |||||
): | |||||
self.generate(node, 1) | |||||
# Parking and then unparking a block should not change its validity, | # Parking and then unparking a block should not change its validity, | ||||
# and invaliding and reconsidering a block should not change its | # and invaliding and reconsidering a block should not change its | ||||
# parked state. See the following test cases: | # parked state. See the following test cases: | ||||
self.log.info("Test invalidate, park, unpark, reconsider...") | self.log.info("Test invalidate, park, unpark, reconsider...") | ||||
self.generate(node, 1, sync_fun=self.no_op) | self.generate(node, 1, sync_fun=self.no_op) | ||||
tip = node.getbestblockhash() | tip = node.getbestblockhash() | ||||
self.generate(node, 1, sync_fun=self.no_op) | self.generate(node, 1, sync_fun=self.no_op) | ||||
bad_tip = node.getbestblockhash() | bad_tip = node.getbestblockhash() | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |