test: Avoid hard time.sleep(1) in feature_init.py
What changed, and why it matters
This commit changes only a test file in Bitcoin Core. It replaces a fixed one-second sleep with a smarter wait that pauses until a specific RPC command is actually running. There is no change to production code, no security fix, and no vulnerability.
No security action needed. Treat as a normal test-quality improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/feature_init.py, the hard-coded time.sleep(1) is removed and replaced with self.wait_until(…) polling node.cli.getrpcinfo()[‘active_commands’] until ‘waitforblockheight’ appears. This is a test reliability/performance improvement, not a security patch.
Changed components
test/functional/feature_init.pyInspect captured patch +2 / −2
diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py
index 0fa99470..f3572013 100755
--- a/test/functional/feature_init.py
+++ b/test/functional/feature_init.py
@@ -10,7 +10,6 @@ import platform
import shutil
import signal
import subprocess
-import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import (
@@ -272,7 +271,8 @@ class InitTest(BitcoinTestFramework):
# returns early it will return the current block height.
self.log.debug(f"Calling waitforblockheight with {self.rpc_timeout} sec RPC timeout")
fut = ex.submit(node.waitforblockheight, height=current_height+1, timeout=self.rpc_timeout*1000*2)
- time.sleep(1)
+
+ self.wait_until(lambda: any(c["method"] == "waitforblockheight" for c in node.cli.getrpcinfo()["active_commands"]))
self.log.debug(f"Sending break signal to pid {node.process.pid}")
if platform.system() == 'Windows':
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.