qa: Replace always-escaped regexps with "X in Y"
What changed, and why it matters
This is a small code-quality cleanup in Bitcoin Core's test framework. It replaces regular-expression searches with simple string searches because the search strings were always being escaped anyway, making regex unnecessary. There is no security impact.
No security action needed. This is a benign refactor of test-only code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/test_framework/test_node.py. It changes two log-search checks from re.search(re.escape(…), log, flags=re.MULTILINE) to plain substring checks (unexpected_msg in log and expected_msg not in log). Since re.escape() neutralizes all regex metacharacters, the original behavior was already equivalent to substring matching. The change is behavior-preserving and only affects the internal test framework, not production node code.
Changed components
test/functional/test_framework/test_node.pyInspect captured patch +2 / −2
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 0540ca34..3a13a923 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -559,10 +559,10 @@ class TestNode():
log = dl.read()
print_log = " - " + "\n - ".join(log.splitlines())
for unexpected_msg in unexpected_msgs:
- if re.search(re.escape(unexpected_msg), log, flags=re.MULTILINE):
+ if unexpected_msg in log:
self._raise_assertion_error('Unexpected message "{}" partially matches log:\n\n{}\n\n'.format(unexpected_msg, print_log))
for expected_msg in expected_msgs:
- if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
+ if expected_msg not in log:
found = False
if found:
return
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.