test: Catch CalledProcessError to support --usecli in feature_dbcrash.py
What changed, and why it matters
This is a minor fix to a Bitcoin Core functional test script. It allows the dbcrash test to be run with the --usecli option by catching an additional error type that occurs when commands are sent through the bitcoin-cli tool instead of the direct RPC interface. It does not change the production Bitcoin node code and has no security impact on real users.
No security action required. This is a test-only change and can be reviewed as part of normal QA/test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/feature_dbcrash.py. It removes self.supports_cli = False, imports the subprocess module, and catches subprocess.CalledProcessError in the submitblock wrapper. When the test is run with –usecli, RPC calls are dispatched via bitcoin-cli as a subprocess; if the node has crashed, bitcoin-cli exits non-zero, raising CalledProcessError. Previously this was uncaught because the test framework declared it did not support CLI mode. The change only affects test error handling.
Changed components
test/functional/feature_dbcrash.pyInspect captured patch +4 / −1
diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py
index cc94be78..6b6c63c4 100755
--- a/test/functional/feature_dbcrash.py
+++ b/test/functional/feature_dbcrash.py
@@ -28,6 +28,7 @@
import errno
import http.client
import random
+import subprocess
import time
from test_framework.blocktools import COINBASE_MATURITY
@@ -49,7 +50,6 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
self.rpc_timeout = 480
- self.supports_cli = False
# Set -maxmempool=0 to turn off mempool memory sharing with dbcache
self.base_args = [
@@ -113,6 +113,9 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
except (http.client.CannotSendRequest, http.client.RemoteDisconnected) as e:
self.log.debug(f"node {node_index} submitblock raised exception: {e}")
return False
+ except subprocess.CalledProcessError as e:
+ self.log.debug(f"node {node_index} submitblock raised CalledProcessError: {e}")
+ return False
except OSError as e:
self.log.debug(f"node {node_index} submitblock raised OSError exception: errno={e.errno}")
if e.errno in [errno.EPIPE, errno.ECONNREFUSED, errno.ECONNRESET]:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.