Merge bitcoin/bitcoin#34137: test: Avoid hard time.sleep(1) in feature_init.py
fa727e3ec9test: Avoid hard time.sleep(1) in feature_init.py (MarcoFalke) Pull request description: Using a hard-coded `time.sleep` in the tests is usually confusing and brittle. For example, the one in `break_wait_test`: * Is confusing, because it does not explain why it is needed. * On fast hardware will just lead to a useless delay. * On slow hardware may lead to an intermittent, and confusing test failure. Fix all issues by replacing it with the proper condition to wait on. ACKs for top commit: Sjors: utACKfa727e3ec9rkrux: tACKfa727e3janb84: tACKfa727e3ec9Tree-SHA512: 7b59496a1b9b8044548423ad517ff03e98521685cf65499cd0ef499d6fd3d72ad374c92ca815436675ed6ae7be508a5a1afce699b804a384d7aee6a195d8d972
This commit is contained in:
1 file changed
+2
-2
@@ -10,7 +10,6 @@ import platform
|
|||||||
import shutil
|
import shutil
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.test_node import (
|
from test_framework.test_node import (
|
||||||
@@ -272,7 +271,8 @@ class InitTest(BitcoinTestFramework):
|
|||||||
# returns early it will return the current block height.
|
# returns early it will return the current block height.
|
||||||
self.log.debug(f"Calling waitforblockheight with {self.rpc_timeout} sec RPC timeout")
|
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)
|
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}")
|
self.log.debug(f"Sending break signal to pid {node.process.pid}")
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
|
|||||||
Reference in new issue
Block a user