Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-finalize-block.py
Show All 21 Lines | |||||
class FinalizeBlockTest(BitcoinTestFramework): | class FinalizeBlockTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 3 | self.num_nodes = 3 | ||||
self.extra_args = [["-finalizationdelay=0"], | self.extra_args = [["-finalizationdelay=0"], | ||||
["-finalizationdelay=0"], []] | ["-finalizationdelay=0"], []] | ||||
self.finalization_delay = 2 * 60 * 60 | self.finalization_delay = 2 * 60 * 60 | ||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0] | node = self.nodes[1] | ||||
deadalnix: I don't see any valid reason why this is necessary. | |||||
self.mocktime = int(time.time()) | self.mocktime = int(time.time()) | ||||
self.log.info("Test block finalization...") | self.log.info("Test block finalization...") | ||||
node.generatetoaddress(10, node.get_deterministic_priv_key().address) | node.generatetoaddress(10, node.get_deterministic_priv_key().address) | ||||
tip = node.getbestblockhash() | tip = node.getbestblockhash() | ||||
node.finalizeblock(tip) | node.finalizeblock(tip) | ||||
assert_equal(node.getbestblockhash(), tip) | assert_equal(node.getbestblockhash(), tip) | ||||
assert_equal(node.getfinalizedblockhash(), tip) | assert_equal(node.getfinalizedblockhash(), tip) | ||||
def wait_for_tip(node, tip): | def wait_for_tip(node, tip): | ||||
def check_tip(): | def check_tip(): | ||||
return node.getbestblockhash() == tip | return node.getbestblockhash() == tip | ||||
wait_until(check_tip) | wait_until(check_tip) | ||||
alt_node = self.nodes[1] | alt_node = self.nodes[0] | ||||
deadalnixUnsubmitted Not Done Inline Actionsdito deadalnix: dito | |||||
wait_for_tip(alt_node, tip) | wait_for_tip(alt_node, tip) | ||||
alt_node.invalidateblock(tip) | alt_node.invalidateblock(tip) | ||||
# We will use this later | # We will use this later | ||||
fork_block = alt_node.getbestblockhash() | fork_block = alt_node.getbestblockhash() | ||||
# Node 0 should not accept the whole alt_node's chain due to tip being finalized, | # Node 0 should not accept the whole alt_node's chain due to tip being finalized, | ||||
# even though it is longer. | # even though it is longer. | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |
I don't see any valid reason why this is necessary.