Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | def __init__(self, i, datadir, host, rpc_port, p2p_port, timewait, binary, stderr, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False): | ||||
self.running = False | self.running = False | ||||
self.process = None | self.process = None | ||||
self.rpc_connected = False | self.rpc_connected = False | ||||
self.rpc = None | self.rpc = None | ||||
self.url = None | self.url = None | ||||
self.relay_fee_cache = None | self.relay_fee_cache = None | ||||
self.log = logging.getLogger('TestFramework.node{}'.format(i)) | self.log = logging.getLogger('TestFramework.node{}'.format(i)) | ||||
self.cleanup_on_exit = True # Whether to kill the node when this object goes away | |||||
jasonbcox: Move comment on line above this one | |||||
self.p2ps = [] | self.p2ps = [] | ||||
def __del__(self): | |||||
# Ensure that we don't leave any bitcoind processes lying around after | |||||
# the test ends | |||||
if self.process and self.cleanup_on_exit: | |||||
# Should only happen on test failure | |||||
# Avoid using logger, as that may have already been shutdown when | |||||
# this destructor is called. | |||||
print("Cleaning up leftover process") | |||||
self.process.kill() | |||||
def __getattr__(self, name): | def __getattr__(self, name): | ||||
"""Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" | """Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" | ||||
if self.use_cli: | if self.use_cli: | ||||
return getattr(self.cli, name) | return getattr(self.cli, name) | ||||
else: | else: | ||||
assert self.rpc is not None, "Error: RPC not initialized" | assert self.rpc is not None, "Error: RPC not initialized" | ||||
assert self.rpc_connected, "Error: No RPC connection" | assert self.rpc_connected, "Error: No RPC connection" | ||||
return getattr(self.rpc, name) | return getattr(self.rpc, name) | ||||
▲ Show 20 Lines • Show All 274 Lines • Show Last 20 Lines |
Move comment on line above this one