Skip to content

Commit de7e586

Browse files
author
MarcoFalke
committed
Merge #12810: [Tests] Fix a typo at assert_start_raises_init_error() and use specific exception for initialization error
8394300 [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
2 parents 40f4baf + 8394300 commit de7e586

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/functional/test_framework/test_node.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030

3131
BITCOIND_PROC_WAIT_TIMEOUT = 60
3232

33+
34+
class FailedToStartError(Exception):
35+
"""Raised when a node fails to start correctly."""
36+
37+
3338
class TestNode():
3439
"""A class for representing a bitcoind node under test.
3540
@@ -102,7 +107,8 @@ def wait_for_rpc_connection(self):
102107
# Poll at a rate of four times per second
103108
poll_per_s = 4
104109
for _ in range(poll_per_s * self.rpc_timeout):
105-
assert self.process.poll() is None, "bitcoind exited with status %i during initialization" % self.process.returncode
110+
if self.process.poll() is not None:
111+
raise FailedToStartError('bitcoind exited with status {} during initialization'.format(self.process.returncode))
106112
try:
107113
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
108114
self.rpc.getblockcount()
@@ -179,9 +185,9 @@ def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, par
179185
self.start(extra_args, stderr=log_stderr, *args, **kwargs)
180186
self.wait_for_rpc_connection()
181187
self.stop_node()
182-
self.wait_util_stopped()
183-
except Exception as e:
184-
assert 'bitcoind exited' in str(e) # node must have shutdown
188+
self.wait_until_stopped()
189+
except FailedToStartError as e:
190+
self.log.debug('bitcoind failed to start: %s', e)
185191
self.running = False
186192
self.process = None
187193
# Check stderr for expected message

0 commit comments

Comments
 (0)