[qa] TestNode: Add wait_until_stopped helper method

This commit is contained in:
MarcoFalke
2017-08-16 08:52:24 -07:00
parent 777519bd96
commit faa8d9581a
5 changed files with 24 additions and 22 deletions

View File

@@ -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"""