|
|
@ -30,6 +30,11 @@ JSONDecodeError = getattr(json, "JSONDecodeError", ValueError)
|
|
|
|
|
|
|
|
|
|
|
|
BITCOIND_PROC_WAIT_TIMEOUT = 60
|
|
|
|
BITCOIND_PROC_WAIT_TIMEOUT = 60
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FailedToStartError(Exception):
|
|
|
|
|
|
|
|
"""Raised when a node fails to start correctly."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestNode():
|
|
|
|
class TestNode():
|
|
|
|
"""A class for representing a bitcoind node under test.
|
|
|
|
"""A class for representing a bitcoind node under test.
|
|
|
|
|
|
|
|
|
|
|
@ -102,7 +107,8 @@ class TestNode():
|
|
|
|
# Poll at a rate of four times per second
|
|
|
|
# Poll at a rate of four times per second
|
|
|
|
poll_per_s = 4
|
|
|
|
poll_per_s = 4
|
|
|
|
for _ in range(poll_per_s * self.rpc_timeout):
|
|
|
|
for _ in range(poll_per_s * self.rpc_timeout):
|
|
|
|
assert self.process.poll() is None, "bitcoind exited with status %i during initialization" % self.process.returncode
|
|
|
|
if self.process.poll() is not None:
|
|
|
|
|
|
|
|
raise FailedToStartError('bitcoind exited with status {} during initialization'.format(self.process.returncode))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
|
|
|
|
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
|
|
|
|
self.rpc.getblockcount()
|
|
|
|
self.rpc.getblockcount()
|
|
|
@ -179,9 +185,9 @@ class TestNode():
|
|
|
|
self.start(extra_args, stderr=log_stderr, *args, **kwargs)
|
|
|
|
self.start(extra_args, stderr=log_stderr, *args, **kwargs)
|
|
|
|
self.wait_for_rpc_connection()
|
|
|
|
self.wait_for_rpc_connection()
|
|
|
|
self.stop_node()
|
|
|
|
self.stop_node()
|
|
|
|
self.wait_util_stopped()
|
|
|
|
self.wait_until_stopped()
|
|
|
|
except Exception as e:
|
|
|
|
except FailedToStartError as e:
|
|
|
|
assert 'bitcoind exited' in str(e) # node must have shutdown
|
|
|
|
self.log.debug('bitcoind failed to start: %s', e)
|
|
|
|
self.running = False
|
|
|
|
self.running = False
|
|
|
|
self.process = None
|
|
|
|
self.process = None
|
|
|
|
# Check stderr for expected message
|
|
|
|
# Check stderr for expected message
|
|
|
|