Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show All 24 Lines | from .util import ( | ||||
connect_nodes_bi, | connect_nodes_bi, | ||||
disable_mocktime, | disable_mocktime, | ||||
disconnect_nodes, | disconnect_nodes, | ||||
enable_coverage, | enable_coverage, | ||||
enable_mocktime, | enable_mocktime, | ||||
get_mocktime, | get_mocktime, | ||||
get_rpc_proxy, | get_rpc_proxy, | ||||
initialize_datadir, | initialize_datadir, | ||||
get_datadir_path, | |||||
log_filename, | log_filename, | ||||
p2p_port, | p2p_port, | ||||
rpc_url, | rpc_url, | ||||
set_node_times, | set_node_times, | ||||
start_node, | start_node, | ||||
start_nodes, | start_nodes, | ||||
stop_node, | stop_node, | ||||
stop_nodes, | stop_nodes, | ||||
sync_blocks, | sync_blocks, | ||||
sync_mempools, | sync_mempools, | ||||
wait_for_bitcoind_start, | wait_for_bitcoind_start, | ||||
) | ) | ||||
from .authproxy import JSONRPCException | from .authproxy import JSONRPCException | ||||
class TestStatus(Enum): | class TestStatus(Enum): | ||||
PASSED = 1 | PASSED = 1 | ||||
FAILED = 2 | FAILED = 2 | ||||
SKIPPED = 3 | SKIPPED = 3 | ||||
TEST_EXIT_PASSED = 0 | TEST_EXIT_PASSED = 0 | ||||
TEST_EXIT_FAILED = 1 | TEST_EXIT_FAILED = 1 | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | def _initialize_chain(self, test_dir, num_nodes, cachedir): | ||||
datadir = initialize_datadir(cachedir, i) | datadir = initialize_datadir(cachedir, i) | ||||
args = [os.getenv("BITCOIND", "bitcoind"), "-server", | args = [os.getenv("BITCOIND", "bitcoind"), "-server", | ||||
"-keypool=1", "-datadir=" + datadir, "-discover=0"] | "-keypool=1", "-datadir=" + datadir, "-discover=0"] | ||||
if i > 0: | if i > 0: | ||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0))) | args.append("-connect=127.0.0.1:" + str(p2p_port(0))) | ||||
bitcoind_processes[i] = subprocess.Popen(args) | bitcoind_processes[i] = subprocess.Popen(args) | ||||
self.log.debug( | self.log.debug( | ||||
"initialize_chain: bitcoind started, waiting for RPC to come up") | "initialize_chain: bitcoind started, waiting for RPC to come up") | ||||
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i) | wait_for_bitcoind_start(bitcoind_processes[i], datadir, i) | ||||
self.log.debug("initialize_chain: RPC successfully started") | self.log.debug("initialize_chain: RPC successfully started") | ||||
self.nodes = [] | self.nodes = [] | ||||
for i in range(MAX_NODES): | for i in range(MAX_NODES): | ||||
try: | try: | ||||
self.nodes.append(get_rpc_proxy(rpc_url(i), i)) | self.nodes.append(get_rpc_proxy( | ||||
rpc_url(get_datadir_path(cachedir, i), i), i)) | |||||
except: | except: | ||||
self.log.exception("Error connecting to node %d" % i) | self.log.exception("Error connecting to node %d" % i) | ||||
sys.exit(1) | sys.exit(1) | ||||
# Create a 200-block-long chain; each of the 4 first nodes | # Create a 200-block-long chain; each of the 4 first nodes | ||||
# gets 25 mature blocks and 25 immature. | # gets 25 mature blocks and 25 immature. | ||||
# Note: To preserve compatibility with older versions of | # Note: To preserve compatibility with older versions of | ||||
# initialize_chain, only 4 nodes will generate coins. | # initialize_chain, only 4 nodes will generate coins. | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |