Skip to content

Commit 6ddacfb

Browse files
dongcarlfurszy
authored andcommitted
tests: Modify rpc_bind to conform to bitcoin#14532 behaviour.
- Even when rpcallowip is specified, only bind localhost - Explicitly bind in run_allowip_test
1 parent d6f1b39 commit 6ddacfb

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
@@ -56,9 +56,12 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
5656
at a non-localhost IP.
5757
'''
5858
self.log.info("Allow IP test for %s:%d" % (rpchost, rpcport))
59-
base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
59+
node_args = \
60+
['-disablewallet', '-nolisten'] + \
61+
['-rpcallowip='+x for x in allow_ips] + \
62+
['-rpcbind='+addr for addr in ['127.0.0.1', "%s:%d" % (rpchost, rpcport)]] # Bind to localhost as well so start_nodes doesn't hang
6063
self.nodes[0].rpchost = None
61-
self.start_nodes([base_args])
64+
self.start_nodes([node_args])
6265
# connect to node through non-loopback interface
6366
node = get_rpc_proxy(rpc_url(get_datadir_path(self.options.tmpdir, 0), 0, "%s:%d" % (rpchost, rpcport)), 0, coveragedir=self.options.coveragedir)
6467
node.getnetworkinfo()
@@ -109,9 +112,9 @@ def _run_loopback_tests(self):
109112
# check default without rpcallowip (IPv4 and IPv6 localhost)
110113
self.run_bind_test(None, '127.0.0.1', [],
111114
[('127.0.0.1', self.defaultport), ('::1', self.defaultport)])
112-
# check default with rpcallowip (IPv6 any)
115+
# check default with rpcallowip (IPv4 and IPv6 localhost)
113116
self.run_bind_test(['127.0.0.1'], '127.0.0.1', [],
114-
[('::0', self.defaultport)])
117+
[('127.0.0.1', self.defaultport), ('::1', self.defaultport)])
115118
# check only IPv6 localhost (explicit)
116119
self.run_bind_test(['[::1]'], '[::1]', ['[::1]'],
117120
[('::1', self.defaultport)])

0 commit comments

Comments
 (0)