aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-08-16 08:52:24 -0700
committerMarcoFalke <falke.marco@gmail.com>2017-09-06 09:41:21 -0700
commitfaa8d9581affde35a8242c63fca8a52004d4f943 (patch)
tree20cb6a1f016bffae3846df2484424dd1ce5d0efa /test/functional/test_framework/test_node.py
parent777519bd96f68c18150a0f5942f8f97a91937f5e (diff)
downloadbitcoin-faa8d9581affde35a8242c63fca8a52004d4f943.tar.xz
[qa] TestNode: Add wait_until_stopped helper method
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"""