Skip to content

Commit c454395

Browse files
committed
Merge bitcoin/bitcoin#27895: test: clean up is node stopped
6779e6e test: clean up is node stopped (dimitaracev) Pull request description: Fixes #27893 Use f'strings for the message when asserting `expected_ret_code` and `return_code`. Change the `expected_ret_code` from an optional to have a default value of `0`. cc MarcoFalke ACKs for top commit: MarcoFalke: lgtm ACK 6779e6e stickies-v: ACK 6779e6e brunoerg: ACK 6779e6e Tree-SHA512: af84e7ffe467ced29236dee9206687786a2efb89ab8b039c3ebfb93ea23fc273206cd51f20c9fb6bee4135770e9a649538942571d9c0be83ba9535fa8e59cb28
2 parents 9372ec7 + 6779e6e commit c454395

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/functional/test_framework/test_node.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def stop_node(self, expected_stderr='', *, wait=0, wait_until_stopped=True):
365365
if wait_until_stopped:
366366
self.wait_until_stopped()
367367

368-
def is_node_stopped(self, expected_ret_code=None):
368+
def is_node_stopped(self, expected_ret_code=0):
369369
"""Checks whether the node has stopped.
370370
371371
Returns True if the node has stopped. False otherwise.
@@ -377,13 +377,8 @@ def is_node_stopped(self, expected_ret_code=None):
377377
return False
378378

379379
# process has stopped. Assert that it didn't return an error code.
380-
# unless 'expected_ret_code' is provided.
381-
if expected_ret_code is not None:
382-
assert return_code == expected_ret_code, self._node_msg(
383-
"Node returned unexpected exit code (%d) vs (%d) when stopping" % (return_code, expected_ret_code))
384-
else:
385-
assert return_code == 0, self._node_msg(
386-
"Node returned non-zero exit code (%d) when stopping" % return_code)
380+
assert return_code == expected_ret_code, self._node_msg(
381+
f"Node returned unexpected exit code ({return_code}) vs ({expected_ret_code}) when stopping")
387382
self.running = False
388383
self.process = None
389384
self.rpc_connected = False
@@ -392,7 +387,7 @@ def is_node_stopped(self, expected_ret_code=None):
392387
return True
393388

394389
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error=False):
395-
expected_ret_code = 1 if expect_error else None # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
390+
expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
396391
wait_until_helper(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code), timeout=timeout, timeout_factor=self.timeout_factor)
397392

398393
def replace_in_config(self, replacements):

0 commit comments

Comments
 (0)