Skip to content

Commit 8394300

Browse files
committed
[Tests] fix a typo in TestNode.assert_start_raises_init_error()
Also, use specific exception for testing TestNode initialization failure.
1 parent 624bee9 commit 8394300

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)