test: check for output to stdout in `TestShell` test
What changed, and why it matters
This commit only changes a test file. It improves an existing test by checking that a warning message ('TestShell is already running!') is actually printed to the screen when a second TestShell is started. There is no change to Bitcoin Core's production code, no security fix, and no vulnerability.
No security action needed. This is a routine test-quality improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/feature_framework_testshell.py. It replaces a TODO comment with an assertion that verifies stdout output using contextlib.redirect_stdout and io.StringIO. The behavior under test (TestShell singleton enforcement and its stdout message) already existed; this commit merely completes the test coverage. No consensus, networking, wallet, or cryptographic code is touched.
Changed components
test/functional/feature_framework_testshell.pyInspect captured patch +7 / −2
diff --git a/test/functional/feature_framework_testshell.py b/test/functional/feature_framework_testshell.py
index cb39d9d0..75ba4e69 100755
--- a/test/functional/feature_framework_testshell.py
+++ b/test/functional/feature_framework_testshell.py
@@ -4,7 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests for the `TestShell` submodule."""
+from contextlib import redirect_stdout
from decimal import Decimal
+from io import StringIO
from pathlib import Path
# Note that we need to import from functional test framework modules
@@ -24,8 +26,11 @@ def run_testshell_doc_example(functional_tests_dir):
test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
try:
assert test is not None
- test2 = TestShell().setup()
- assert test2 is None # TODO: check for "TestShell is already running!" output to stdout
+ stdout_buf = StringIO()
+ with redirect_stdout(stdout_buf):
+ test2 = TestShell().setup()
+ assert test2 is None
+ assert_equal(stdout_buf.getvalue().rstrip(), "TestShell is already running!")
assert_equal(test.nodes[0].getblockchaininfo()["blocks"], 0)
if test.is_wallet_compiled():
res = test.nodes[0].createwallet('default')
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.