Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpcbind_test.py
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | def run_allowip_test(self, allow_ips, rpchost, rpcport): | ||||
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].rpchost = 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" % ( | node = get_rpc_proxy(rpc_url(get_datadir_path( | ||||
rpchost, rpcport)), 0, coveragedir=self.options.coveragedir) | self.options.tmpdir, 0), 0, rpchost, rpcport), 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.") | ||||
# find the first non-loopback interface for testing | # find the first non-loopback interface for testing | ||||
Show All 9 Lines | def run_test(self): | ||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) | s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) | ||||
s.connect(("::1", 1)) | s.connect(("::1", 1)) | ||||
s.close | s.close | ||||
except OSError: | except OSError: | ||||
raise SkipTest("This test requires IPv6 support.") | raise SkipTest("This test requires IPv6 support.") | ||||
self.log.info("Using interface %s for testing" % non_loopback_ip) | self.log.info("Using interface %s for testing" % non_loopback_ip) | ||||
defaultport = rpc_port(0) | defaultport = self.rpc_port(0) | ||||
# check default without rpcallowip (IPv4 and IPv6 localhost) | # check default without rpcallowip (IPv4 and IPv6 localhost) | ||||
self.run_bind_test(None, '127.0.0.1', [], | self.run_bind_test(None, '127.0.0.1', [], | ||||
[('127.0.0.1', defaultport), ('::1', defaultport)]) | [('127.0.0.1', defaultport), ('::1', defaultport)]) | ||||
# check default with rpcallowip (IPv6 any) | # check default with rpcallowip (IPv6 any) | ||||
self.run_bind_test(['127.0.0.1'], '127.0.0.1', [], | self.run_bind_test(['127.0.0.1'], '127.0.0.1', [], | ||||
[('::0', defaultport)]) | [('::0', defaultport)]) | ||||
# check only IPv4 localhost (explicit) | # check only IPv4 localhost (explicit) | ||||
Show All 31 Lines |