Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
| Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | class TestNode(): | ||||
| - state about the node (whether it's running, etc) | - state about the node (whether it's running, etc) | ||||
| - a Python subprocess.Popen object representing the running process | - a Python subprocess.Popen object representing the running process | ||||
| - an RPC connection to the node | - an RPC connection to the node | ||||
| - one or more P2P connections to the node | - one or more P2P connections to the node | ||||
| To make things easier for the test writer, any unrecognised messages will | To make things easier for the test writer, any unrecognised messages will | ||||
| be dispatched to the RPC connection.""" | be dispatched to the RPC connection.""" | ||||
| 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): | def __init__(self, i, datadir, host, rpc_port, p2p_port, timewait, bitcoind, bitcoin_cli, stderr, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False): | ||||
| self.index = i | self.index = i | ||||
| self.datadir = datadir | self.datadir = datadir | ||||
| self.host = host | self.host = host | ||||
| self.rpc_port = rpc_port | self.rpc_port = rpc_port | ||||
| self.p2p_port = p2p_port | self.p2p_port = p2p_port | ||||
| self.name = "testnode-{}".format(i) | self.name = "testnode-{}".format(i) | ||||
| if timewait: | if timewait: | ||||
| self.rpc_timeout = timewait | self.rpc_timeout = timewait | ||||
| else: | else: | ||||
| # Wait for up to 60 seconds for the RPC server to respond | # Wait for up to 60 seconds for the RPC server to respond | ||||
| self.rpc_timeout = 60 | self.rpc_timeout = 60 | ||||
| if binary is None: | self.binary = bitcoind | ||||
| self.binary = os.getenv("BITCOIND", "bitcoind") | |||||
| else: | |||||
| self.binary = binary | |||||
| if not os.path.isfile(self.binary): | if not os.path.isfile(self.binary): | ||||
| raise FileNotFoundError( | raise FileNotFoundError( | ||||
| "Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOIND=<path/to/bitcoind> {}".format(self.binary, sys.argv[0])) | "Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOIND=<path/to/bitcoind> {}".format(self.binary, sys.argv[0])) | ||||
| self.stderr = stderr | self.stderr = stderr | ||||
| self.coverage_dir = coverage_dir | self.coverage_dir = coverage_dir | ||||
| if extra_conf != None: | if extra_conf != None: | ||||
| append_config(datadir, extra_conf) | append_config(datadir, extra_conf) | ||||
| # Most callers will just need to add extra args to the default list | # Most callers will just need to add extra args to the default list | ||||
| # below. | # below. | ||||
| # For those callers that need more flexibity, they can access the | # For those callers that need more flexibity, they can access the | ||||
| # default args using the provided facilities | # default args using the provided facilities | ||||
| self.extra_args = extra_args | self.extra_args = extra_args | ||||
| self.default_args = ["-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", | self.default_args = ["-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", | ||||
| "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=" + self.name] | "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=" + self.name] | ||||
| cli_path = os.getenv("BITCOINCLI", "bitcoin-cli") | if not os.path.isfile(bitcoin_cli): | ||||
| if not os.path.isfile(cli_path): | |||||
| raise FileNotFoundError( | raise FileNotFoundError( | ||||
| "Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOINCLI=<path/to/bitcoin-cli> {}".format(cli_path, sys.argv[0])) | "Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOINCLI=<path/to/bitcoin-cli> {}".format(bitcoin_cli, sys.argv[0])) | ||||
| self.cli = TestNodeCLI(cli_path, self.datadir) | self.cli = TestNodeCLI(bitcoin_cli, self.datadir) | ||||
| self.use_cli = use_cli | self.use_cli = use_cli | ||||
| 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 | ||||
| ▲ Show 20 Lines • Show All 297 Lines • Show Last 20 Lines | |||||