|
|
@ -17,9 +17,12 @@ from .util import ( |
|
|
|
assert_equal, |
|
|
|
assert_equal, |
|
|
|
get_rpc_proxy, |
|
|
|
get_rpc_proxy, |
|
|
|
rpc_url, |
|
|
|
rpc_url, |
|
|
|
|
|
|
|
wait_until, |
|
|
|
) |
|
|
|
) |
|
|
|
from .authproxy import JSONRPCException |
|
|
|
from .authproxy import JSONRPCException |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BITCOIND_PROC_WAIT_TIMEOUT = 60 |
|
|
|
|
|
|
|
|
|
|
|
class TestNode(): |
|
|
|
class TestNode(): |
|
|
|
"""A class for representing a bitcoind node under test. |
|
|
|
"""A class for representing a bitcoind node under test. |
|
|
|
|
|
|
|
|
|
|
@ -125,14 +128,20 @@ class TestNode(): |
|
|
|
if not self.running: |
|
|
|
if not self.running: |
|
|
|
return True |
|
|
|
return True |
|
|
|
return_code = self.process.poll() |
|
|
|
return_code = self.process.poll() |
|
|
|
if return_code is not None: |
|
|
|
if return_code is None: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
# process has stopped. Assert that it didn't return an error code. |
|
|
|
# process has stopped. Assert that it didn't return an error code. |
|
|
|
assert_equal(return_code, 0) |
|
|
|
assert_equal(return_code, 0) |
|
|
|
self.running = False |
|
|
|
self.running = False |
|
|
|
self.process = None |
|
|
|
self.process = None |
|
|
|
|
|
|
|
self.rpc_connected = False |
|
|
|
|
|
|
|
self.rpc = None |
|
|
|
self.log.debug("Node stopped") |
|
|
|
self.log.debug("Node stopped") |
|
|
|
return True |
|
|
|
return True |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT): |
|
|
|
|
|
|
|
wait_until(self.is_node_stopped, timeout=timeout) |
|
|
|
|
|
|
|
|
|
|
|
def node_encrypt_wallet(self, passphrase): |
|
|
|
def node_encrypt_wallet(self, passphrase): |
|
|
|
""""Encrypts the wallet. |
|
|
|
""""Encrypts the wallet. |
|
|
@ -140,10 +149,7 @@ class TestNode(): |
|
|
|
This causes bitcoind to shutdown, so this method takes |
|
|
|
This causes bitcoind to shutdown, so this method takes |
|
|
|
care of cleaning up resources.""" |
|
|
|
care of cleaning up resources.""" |
|
|
|
self.encryptwallet(passphrase) |
|
|
|
self.encryptwallet(passphrase) |
|
|
|
while not self.is_node_stopped(): |
|
|
|
self.wait_until_stopped() |
|
|
|
time.sleep(0.1) |
|
|
|
|
|
|
|
self.rpc = None |
|
|
|
|
|
|
|
self.rpc_connected = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestNodeCLI(): |
|
|
|
class TestNodeCLI(): |
|
|
|
"""Interface to bitcoin-cli for an individual node""" |
|
|
|
"""Interface to bitcoin-cli for an individual node""" |
|
|
|