Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
Lint: Code style violation: '/home/nico/bitcoin-abc/test/functional/test_framework/test_node.py' has code style errors. | |||||
# Copyright (c) 2017 The Bitcoin Core developers | # Copyright (c) 2017 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Class for bitcoind node under test""" | """Class for bitcoind node under test""" | ||||
import decimal | import decimal | ||||
import errno | import errno | ||||
import http.client | import http.client | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | def __init__(self, i, dirname, extra_args, host, rpc_port, p2p_port, timewait, binary, stderr, mocktime, coverage_dir, 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)) | ||||
# Whether to kill the node when this object goes away | |||||
self.cleanup_on_exit = True | |||||
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 232 Lines • Show Last 20 Lines |
'/home/nico/bitcoin-abc/test/functional/test_framework/test_node.py' has code style errors.