Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# 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 | ||||
import json | import json | ||||
import logging | import logging | ||||
import os | import os | ||||
import re | import re | ||||
import subprocess | import subprocess | ||||
import sys | |||||
import time | import time | ||||
from .authproxy import JSONRPCException | from .authproxy import JSONRPCException | ||||
from .messages import COIN, CTransaction, FromHex | from .messages import COIN, CTransaction, FromHex | ||||
from .util import ( | from .util import ( | ||||
assert_equal, | assert_equal, | ||||
get_rpc_proxy, | get_rpc_proxy, | ||||
p2p_port, | p2p_port, | ||||
Show All 31 Lines | def __init__(self, i, dirname, extra_args, host, rpc_port, p2p_port, timewait, binary, stderr, mocktime, coverage_dir, use_cli=False): | ||||
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: | if binary is None: | ||||
self.binary = os.getenv("BITCOIND", "bitcoind") | self.binary = os.getenv("BITCOIND", "bitcoind") | ||||
else: | else: | ||||
self.binary = binary | self.binary = binary | ||||
if not os.path.isfile(self.binary): | |||||
raise FileNotFoundError( | |||||
"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 | ||||
# 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] | ||||
self.cli = TestNodeCLI( | cli_path = os.getenv("BITCOINCLI", "bitcoin-cli") | ||||
os.getenv("BITCOINCLI", "bitcoin-cli"), self.datadir) | if not os.path.isfile(cli_path): | ||||
raise FileNotFoundError( | |||||
"Binary '{}' could not be found.\nTry setting it manually:\n\tBITCOINCLI=<path/to/bitcoin-cli> {}".format(cli_path, sys.argv[0])) | |||||
self.cli = TestNodeCLI(cli_path, 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 244 Lines • Show Last 20 Lines |