Skip to content

Commit f3cf95f

Browse files
committed
tests: Modify rpc_bind to conform to #14532 behaviour.
- Even when rpcallowip is specified, only bind localhost - Explicitly bind in run_allowip_test
1 parent c62b151 commit f3cf95f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/functional/rpc_bind.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
4848
at a non-localhost IP.
4949
'''
5050
self.log.info("Allow IP test for %s:%d" % (rpchost, rpcport))
51-
base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
51+
node_args = \
52+
['-disablewallet', '-nolisten'] + \
53+
['-rpcallowip='+x for x in allow_ips] + \
54+
['-rpcbind='+addr for addr in ['127.0.0.1', "%s:%d" % (rpchost, rpcport)]] # Bind to localhost as well so start_nodes doesn't hang
5255
self.nodes[0].rpchost = None
53-
self.start_nodes([base_args])
56+
self.start_nodes([node_args])
5457
# connect to node through non-loopback interface
5558
node = get_rpc_proxy(rpc_url(self.nodes[0].datadir, 0, "%s:%d" % (rpchost, rpcport)), 0, coveragedir=self.options.coveragedir)
5659
node.getnetworkinfo()
@@ -101,9 +104,9 @@ def _run_loopback_tests(self):
101104
# check default without rpcallowip (IPv4 and IPv6 localhost)
102105
self.run_bind_test(None, '127.0.0.1', [],
103106
[('127.0.0.1', self.defaultport), ('::1', self.defaultport)])
104-
# check default with rpcallowip (IPv6 any)
107+
# check default with rpcallowip (IPv4 and IPv6 localhost)
105108
self.run_bind_test(['127.0.0.1'], '127.0.0.1', [],
106-
[('::0', self.defaultport)])
109+
[('127.0.0.1', self.defaultport), ('::1', self.defaultport)])
107110
# check only IPv6 localhost (explicit)
108111
self.run_bind_test(['[::1]'], '[::1]', ['[::1]'],
109112
[('::1', self.defaultport)])

0 commit comments

Comments
 (0)