Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_assumevalid.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | def assert_blockchain_height(self, node, height): | ||||
last_height = node.getblock(node.getbestblockhash())['height'] | last_height = node.getblock(node.getbestblockhash())['height'] | ||||
timeout = 10 | timeout = 10 | ||||
while True: | while True: | ||||
time.sleep(0.25) | time.sleep(0.25) | ||||
current_height = node.getblock(node.getbestblockhash())['height'] | current_height = node.getblock(node.getbestblockhash())['height'] | ||||
if current_height != last_height: | if current_height != last_height: | ||||
last_height = current_height | last_height = current_height | ||||
if timeout < 0: | if timeout < 0: | ||||
assert False, "blockchain too short after timeout: %d" % current_height | assert False, "blockchain too short after timeout: {}".format( | ||||
current_height) | |||||
timeout - 0.25 | timeout - 0.25 | ||||
continue | continue | ||||
elif current_height > height: | elif current_height > height: | ||||
assert False, "blockchain too long: %d" % current_height | assert False, "blockchain too long: {}".format(current_height) | ||||
elif current_height == height: | elif current_height == height: | ||||
break | break | ||||
def run_test(self): | def run_test(self): | ||||
# Connect to node0 | # Connect to node0 | ||||
p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |