Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | def stop_nodes(self): | ||||
# Wait for nodes to stop | # Wait for nodes to stop | ||||
node.wait_until_stopped() | node.wait_until_stopped() | ||||
def restart_node(self, i, extra_args=None): | def restart_node(self, i, extra_args=None): | ||||
"""Stop and start a test node""" | """Stop and start a test node""" | ||||
self.stop_node(i) | self.stop_node(i) | ||||
self.start_node(i, extra_args) | self.start_node(i, extra_args) | ||||
def assert_start_raises_init_error(self, i, extra_args=None, expected_msg=None, *args, **kwargs): | |||||
with tempfile.SpooledTemporaryFile(max_size=2**16) as log_stderr: | |||||
try: | |||||
self.start_node( | |||||
i, extra_args, stderr=log_stderr, *args, **kwargs) | |||||
self.stop_node(i) | |||||
except Exception as e: | |||||
assert 'bitcoind exited' in str(e) # node must have shutdown | |||||
self.nodes[i].running = False | |||||
self.nodes[i].process = None | |||||
if expected_msg is not None: | |||||
log_stderr.seek(0) | |||||
stderr = log_stderr.read().decode('utf-8') | |||||
if expected_msg not in stderr: | |||||
raise AssertionError( | |||||
"Expected error \"" + expected_msg + "\" not found in:\n" + stderr) | |||||
else: | |||||
if expected_msg is None: | |||||
assert_msg = "bitcoind should have exited with an error" | |||||
else: | |||||
assert_msg = "bitcoind should have exited with expected error " + expected_msg | |||||
raise AssertionError(assert_msg) | |||||
def wait_for_node_exit(self, i, timeout): | def wait_for_node_exit(self, i, timeout): | ||||
self.nodes[i].process.wait(timeout) | self.nodes[i].process.wait(timeout) | ||||
def split_network(self): | def split_network(self): | ||||
""" | """ | ||||
Split the network of four nodes into nodes 0/1 and 2/3. | Split the network of four nodes into nodes 0/1 and 2/3. | ||||
""" | """ | ||||
disconnect_nodes(self.nodes[1], self.nodes[2]) | disconnect_nodes(self.nodes[1], self.nodes[2]) | ||||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |