Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpcbind_test.py
Show All 26 Lines | def run_bind_test(self, allow_ips, connect_to, addresses, expected): | ||||
matches the expected set. | matches the expected set. | ||||
''' | ''' | ||||
self.log.info("Bind test for %s" % str(addresses)) | self.log.info("Bind test for %s" % str(addresses)) | ||||
expected = [(addr_to_hex(addr), port) for (addr, port) in expected] | expected = [(addr_to_hex(addr), port) for (addr, port) in expected] | ||||
base_args = ['-disablewallet', '-nolisten'] | base_args = ['-disablewallet', '-nolisten'] | ||||
if allow_ips: | if allow_ips: | ||||
base_args += ['-rpcallowip=' + x for x in allow_ips] | base_args += ['-rpcallowip=' + x for x in allow_ips] | ||||
binds = ['-rpcbind=' + addr for addr in addresses] | binds = ['-rpcbind=' + addr for addr in addresses] | ||||
self.nodes[0].rpchost = connect_to | parts = connect_to.split(':') | ||||
if len(parts) == 2: | |||||
self.nodes[0].host = parts[0] | |||||
self.nodes[0].rpc_port = parts[1] | |||||
else: | |||||
self.nodes[0].host = connect_to | |||||
self.nodes[0].rpc_port = rpc_port(self.nodes[0].index) | |||||
self.start_node(0, base_args + binds) | self.start_node(0, base_args + binds) | ||||
pid = self.nodes[0].process.pid | pid = self.nodes[0].process.pid | ||||
assert_equal(set(get_bind_addrs(pid)), set(expected)) | assert_equal(set(get_bind_addrs(pid)), set(expected)) | ||||
self.stop_nodes() | self.stop_nodes() | ||||
def run_allowip_test(self, allow_ips, rpchost, rpcport): | def run_allowip_test(self, allow_ips, rpchost, rpcport): | ||||
''' | ''' | ||||
Start a node with rpcallow IP, and request getnetworkinfo | Start a node with rpcallow IP, and request getnetworkinfo | ||||
at a non-localhost IP. | at a non-localhost IP. | ||||
''' | ''' | ||||
self.log.info("Allow IP test for %s:%d" % (rpchost, rpcport)) | self.log.info("Allow IP test for %s:%d" % (rpchost, rpcport)) | ||||
base_args = ['-disablewallet', '-nolisten'] + \ | base_args = ['-disablewallet', '-nolisten'] + \ | ||||
['-rpcallowip=' + x for x in allow_ips] | ['-rpcallowip=' + x for x in allow_ips] | ||||
self.nodes[0].rpchost = None | self.nodes[0].host = None | ||||
self.start_nodes([base_args]) | self.start_nodes([base_args]) | ||||
# connect to node through non-loopback interface | # connect to node through non-loopback interface | ||||
node = get_rpc_proxy(rpc_url(get_datadir_path(self.options.tmpdir, 0), 0, "%s:%d" % ( | url = rpc_url(get_datadir_path(self.options.tmpdir, 0), | ||||
rpchost, rpcport)), 0, coveragedir=self.options.coveragedir) | rpchost, rpcport) | ||||
node = get_rpc_proxy(url, 0, coveragedir=self.options.coveragedir) | |||||
node.getnetworkinfo() | node.getnetworkinfo() | ||||
self.stop_nodes() | self.stop_nodes() | ||||
def run_test(self): | def run_test(self): | ||||
# due to OS-specific network stats queries, this test works only on Linux | # due to OS-specific network stats queries, this test works only on Linux | ||||
if not sys.platform.startswith('linux'): | if not sys.platform.startswith('linux'): | ||||
raise SkipTest("This test can only be run on linux.") | raise SkipTest("This test can only be run on linux.") | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |