aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2023-06-12 12:13:55 -0400
committerRyan Ofsky <ryan@ofsky.org>2023-06-12 12:54:49 -0400
commitc92fd638860c5b4477851fb3790bc8068f808d3e (patch)
tree063d1c5002af6f03f8a7a3a460314ee2eb3049dc /test/functional
parent361a0c00b3fdac7149c027c2c69e4db60ee5aa86 (diff)
parent61c569ab6069d04079a0831468eb713983919636 (diff)
downloadbitcoin-c92fd638860c5b4477851fb3790bc8068f808d3e.tar.xz
Merge bitcoin/bitcoin#27708: Return EXIT_FAILURE on post-init fatal errors
61c569ab6069d04079a0831468eb713983919636 refactor: decouple early return commands from AppInit (furszy) 4927167f855f8ed3bbf6d2766f61229f742e632a gui: return EXIT_FAILURE on post-init fatal errors (furszy) 3b2c61e8198bcefb1c2343caff1d705951026cc4 Return EXIT_FAILURE on post-init fatal errors (furszy) 3c06926cf21dcca3074ef51506f556b2286c299b refactor: index: use `AbortNode` in fatal error helper (Sebastian Falbesoner) 9ddf7e03a35592617a016418fd320cc93c8d1abd move ThreadImport ABC error to use AbortNode (furszy) Pull request description: It seems odd to return `EXIT_SUCCESS` when the node aborted execution due a fatal internal error or any post-init problem that triggers an unrequested shutdown. e.g. blocks or coins db I/O errors, disconnect block failure, failure during thread import (external blocks loading process error), among others. ACKs for top commit: TheCharlatan: ACK 61c569ab6069d04079a0831468eb713983919636 ryanofsky: Code review ACK 61c569ab6069d04079a0831468eb713983919636 pinheadmz: ACK 61c569ab6069d04079a0831468eb713983919636 theStack: Code-review ACK 61c569ab6069d04079a0831468eb713983919636 Tree-SHA512: 18a59c3acc1c6d12cbc74a20a401e89659740c6477fccb59070c9f97922dfe588468e9e5eef56c5f395762187c34179a5e3954aa5b844787fa13da2e666c63d3
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/feature_abortnode.py2
-rwxr-xr-xtest/functional/test_framework/test_node.py16
2 files changed, 12 insertions, 6 deletions
diff --git a/test/functional/feature_abortnode.py b/test/functional/feature_abortnode.py
index fa1bb6506a..586722aa65 100755
--- a/test/functional/feature_abortnode.py
+++ b/test/functional/feature_abortnode.py
@@ -40,7 +40,7 @@ class AbortNodeTest(BitcoinTestFramework):
# Check that node0 aborted
self.log.info("Waiting for crash")
- self.nodes[0].wait_until_stopped(timeout=5)
+ self.nodes[0].wait_until_stopped(timeout=5, expect_error=True)
self.log.info("Node crashed - now verifying restart fails")
self.nodes[0].assert_start_raises_init_error()
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 51bd697e81..4466bd544f 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -365,7 +365,7 @@ class TestNode():
if wait_until_stopped:
self.wait_until_stopped()
- def is_node_stopped(self):
+ def is_node_stopped(self, expected_ret_code=None):
"""Checks whether the node has stopped.
Returns True if the node has stopped. False otherwise.
@@ -377,8 +377,13 @@ class TestNode():
return False
# process has stopped. Assert that it didn't return an error code.
- assert return_code == 0, self._node_msg(
- "Node returned non-zero exit code (%d) when stopping" % return_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)
self.running = False
self.process = None
self.rpc_connected = False
@@ -386,8 +391,9 @@ class TestNode():
self.log.debug("Node stopped")
return True
- def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
- wait_until_helper(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
+ 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
+ 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):
"""