Merge #12810: [Tests] Fix a typo at assert_start_raises_init_error() and use specific exception for initialization error

8394300859 [Tests] fix a typo in TestNode.assert_start_raises_init_error() (Roman Zeyde)

Pull request description:

  `self.wait_util_stopped()` should be `self.wait_until_stopped()`.

  Also, use a specific Exception subclass for indicating node failure to start (instead of using `AssetionError` and an `except Exception` clause).

  Following https://travis-ci.org/bitcoin/bitcoin/jobs/359066226#L2726 and depending on #12806 (which fixes the root cause of the Travis test failure).

Tree-SHA512: 7bd5a95586a412472ef9dffdb086789d7275ddaf862724e21cebb3418d0c97e6d89b4d1a58375e42114060d028403d6eab89e3a1e9a833ffe8dadf3439ab1fe2
This commit is contained in:
MarcoFalke 2018-03-30 11:39:50 -04:00 committed by pasta
parent c902e6075d
commit 04b375a95d
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -33,6 +33,11 @@ JSONDecodeError = getattr(json, "JSONDecodeError", ValueError)
BITCOIND_PROC_WAIT_TIMEOUT = 60
class FailedToStartError(Exception):
"""Raised when a node fails to start correctly."""
class TestNode():
"""A class for representing a dashd node under test.
@ -124,7 +129,8 @@ class TestNode():
# Poll at a rate of four times per second
poll_per_s = 4
for _ in range(poll_per_s * self.rpc_timeout):
assert self.process.poll() is None, "dashd exited with status %i during initialization" % self.process.returncode
if self.process.poll() is not None:
raise FailedToStartError('dashd exited with status {} during initialization'.format(self.process.returncode))
try:
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
self.rpc.getblockcount()
@ -220,9 +226,9 @@ class TestNode():
self.start(extra_args, stderr=log_stderr, *args, **kwargs)
self.wait_for_rpc_connection()
self.stop_node()
self.wait_util_stopped()
except Exception as e:
assert 'dashd exited' in str(e) # node must have shutdown
self.wait_until_stopped()
except FailedToStartError as e:
self.log.debug('dashd failed to start: %s', e)
self.running = False
self.process = None
# Check stderr for expected message