0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

Merge bitcoin/bitcoin#27895: test: clean up is node stopped

6779e6ed7f 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 6779e6ed7f
  stickies-v:
    ACK 6779e6ed7f
  brunoerg:
    ACK 6779e6ed7f

Tree-SHA512: af84e7ffe467ced29236dee9206687786a2efb89ab8b039c3ebfb93ea23fc273206cd51f20c9fb6bee4135770e9a649538942571d9c0be83ba9535fa8e59cb28
This commit is contained in:
fanquake 2023-06-15 15:39:43 +01:00
commit c454395115
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -365,7 +365,7 @@ class TestNode():
if wait_until_stopped:
self.wait_until_stopped()
def is_node_stopped(self, expected_ret_code=None):
def is_node_stopped(self, expected_ret_code=0):
"""Checks whether the node has stopped.
Returns True if the node has stopped. False otherwise.
@ -377,13 +377,8 @@ class TestNode():
return False
# process has stopped. Assert that it didn't return an error code.
# unless 'expected_ret_code' is provided.
if expected_ret_code is not None:
assert return_code == expected_ret_code, self._node_msg(
"Node returned unexpected exit code (%d) vs (%d) when stopping" % (return_code, expected_ret_code))
else:
assert return_code == 0, self._node_msg(
"Node returned non-zero exit code (%d) when stopping" % return_code)
assert return_code == expected_ret_code, self._node_msg(
f"Node returned unexpected exit code ({return_code}) vs ({expected_ret_code}) when stopping")
self.running = False
self.process = None
self.rpc_connected = False
@ -392,7 +387,7 @@ class TestNode():
return True
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error=False):
expected_ret_code = 1 if expect_error else None # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
wait_until_helper(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code), timeout=timeout, timeout_factor=self.timeout_factor)
def replace_in_config(self, replacements):