aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-rwxr-xr-xtest/functional/test_framework/test_node.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index efb3ac9d16..f58a372a14 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -17,9 +17,12 @@ from .util import (
assert_equal,
get_rpc_proxy,
rpc_url,
+ wait_until,
)
from .authproxy import JSONRPCException
+BITCOIND_PROC_WAIT_TIMEOUT = 60
+
class TestNode():
"""A class for representing a bitcoind node under test.
@@ -125,14 +128,20 @@ class TestNode():
if not self.running:
return True
return_code = self.process.poll()
- if return_code is not None:
- # process has stopped. Assert that it didn't return an error code.
- assert_equal(return_code, 0)
- self.running = False
- self.process = None
- self.log.debug("Node stopped")
- return True
- return False
+ if return_code is None:
+ return False
+
+ # process has stopped. Assert that it didn't return an error code.
+ assert_equal(return_code, 0)
+ self.running = False
+ self.process = None
+ self.rpc_connected = False
+ self.rpc = None
+ self.log.debug("Node stopped")
+ return True
+
+ def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
+ wait_until(self.is_node_stopped, timeout=timeout)
def node_encrypt_wallet(self, passphrase):
""""Encrypts the wallet.
@@ -140,10 +149,7 @@ class TestNode():
This causes bitcoind to shutdown, so this method takes
care of cleaning up resources."""
self.encryptwallet(passphrase)
- while not self.is_node_stopped():
- time.sleep(0.1)
- self.rpc = None
- self.rpc_connected = False
+ self.wait_until_stopped()
class TestNodeCLI():
"""Interface to bitcoin-cli for an individual node"""