Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | |||||
def rpc_port(n): | def rpc_port(n): | ||||
return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | ||||
def rpc_url(datadir, host, port): | def rpc_url(datadir, host, port): | ||||
rpc_u, rpc_p = get_auth_cookie(datadir) | rpc_u, rpc_p = get_auth_cookie(datadir) | ||||
if host == None: | if host is None: | ||||
host = '127.0.0.1' | host = '127.0.0.1' | ||||
return "http://{}:{}@{}:{}".format(rpc_u, rpc_p, host, int(port)) | return "http://{}:{}@{}:{}".format(rpc_u, rpc_p, host, int(port)) | ||||
# Node functions | # Node functions | ||||
################ | ################ | ||||
def initialize_datadir(dirname, n): | def initialize_datadir(dirname, n): | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | def disconnect_nodes(from_node, to_node): | ||||
# wait to disconnect | # wait to disconnect | ||||
wait_until(lambda: [peer['id'] for peer in from_node.getpeerinfo( | wait_until(lambda: [peer['id'] for peer in from_node.getpeerinfo( | ||||
) if to_node.name in peer['subver']] == [], timeout=5) | ) if to_node.name in peer['subver']] == [], timeout=5) | ||||
def connect_nodes(from_node, to_node): | def connect_nodes(from_node, to_node): | ||||
host = to_node.host | host = to_node.host | ||||
if host == None: | if host is None: | ||||
host = '127.0.0.1' | host = '127.0.0.1' | ||||
ip_port = host + ':' + str(to_node.p2p_port) | ip_port = host + ':' + str(to_node.p2p_port) | ||||
from_node.addnode(ip_port, "onetry") | from_node.addnode(ip_port, "onetry") | ||||
# poll until version handshake complete to avoid race conditions | # poll until version handshake complete to avoid race conditions | ||||
# with transaction relaying | # with transaction relaying | ||||
wait_until(lambda: all(peer['version'] != | wait_until(lambda: all(peer['version'] != | ||||
0 for peer in from_node.getpeerinfo())) | 0 for peer in from_node.getpeerinfo())) | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |