test: Use Popen.wait instead of RPC in assert_start_raises_init_error

This commit is contained in:
MarcoFalke 2020-12-10 12:35:28 +01:00
parent eb53c03b36
commit fa918dd537
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -482,11 +482,8 @@ class TestNode():
tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout: tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout:
try: try:
self.start(extra_args, stdout=log_stdout, stderr=log_stderr, *args, **kwargs) self.start(extra_args, stdout=log_stdout, stderr=log_stderr, *args, **kwargs)
self.wait_for_rpc_connection() ret = self.process.wait(timeout=self.rpc_timeout)
self.stop_node() self.log.debug(self._node_msg(f'bitcoind exited with status {ret} during initialization'))
self.wait_until_stopped()
except FailedToStartError as e:
self.log.debug('bitcoind failed to start: %s', e)
self.running = False self.running = False
self.process = None self.process = None
# Check stderr for expected message # Check stderr for expected message
@ -505,11 +502,15 @@ class TestNode():
if expected_msg != stderr: if expected_msg != stderr:
self._raise_assertion_error( self._raise_assertion_error(
'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr)) 'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr))
else: except subprocess.TimeoutExpired:
self.process.kill()
self.running = False
self.process = None
assert_msg = f'bitcoind should have exited within {self.rpc_timeout}s '
if expected_msg is None: if expected_msg is None:
assert_msg = "bitcoind should have exited with an error" assert_msg += "with an error"
else: else:
assert_msg = "bitcoind should have exited with expected error " + expected_msg assert_msg += "with expected error " + expected_msg
self._raise_assertion_error(assert_msg) self._raise_assertion_error(assert_msg)
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):