Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_assumevalid.py
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | def setup_network(self): | ||||
# Start node0. We don't start the other nodes yet since | # Start node0. We don't start the other nodes yet since | ||||
# we need to pre-mine a block with an invalid transaction | # we need to pre-mine a block with an invalid transaction | ||||
# signature so we can pass in the block hash as assumevalid. | # signature so we can pass in the block hash as assumevalid. | ||||
self.start_node(0) | self.start_node(0) | ||||
def send_blocks_until_disconnected(self, p2p_conn): | def send_blocks_until_disconnected(self, p2p_conn): | ||||
"""Keep sending blocks to the node until we're disconnected.""" | """Keep sending blocks to the node until we're disconnected.""" | ||||
for i in range(len(self.blocks)): | for i in range(len(self.blocks)): | ||||
if p2p_conn.state != "connected": | if not p2p_conn.is_connected: | ||||
break | break | ||||
try: | try: | ||||
p2p_conn.send_message(msg_block(self.blocks[i])) | p2p_conn.send_message(msg_block(self.blocks[i])) | ||||
except IOError as e: | except IOError: | ||||
assert str(e) == 'Not connected, no pushbuf' | assert not p2p_conn.is_connected | ||||
break | break | ||||
def assert_blockchain_height(self, node, height): | def assert_blockchain_height(self, node, height): | ||||
"""Wait until the blockchain is no longer advancing and verify it's reached the expected height.""" | """Wait until the blockchain is no longer advancing and verify it's reached the expected 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) | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |