aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortdb3 <106488469+tdb3@users.noreply.github.com>2024-08-20 22:16:33 -0400
committertdb3 <106488469+tdb3@users.noreply.github.com>2024-09-17 20:03:00 -0400
commit73c243965ab256ece089d14173c2d285955e83d5 (patch)
tree4f14637f6e0be0b36721687d1ad10289252c3433 /test
parent6fc4692797121b54de0c54e5b09ee47f322c038a (diff)
test: add tests for invalid rpcbind ports
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_bind.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/rpc_bind.py b/test/functional/rpc_bind.py
index 8c76c1f5f5..0aabba2c46 100755
--- a/test/functional/rpc_bind.py
+++ b/test/functional/rpc_bind.py
@@ -6,6 +6,7 @@
from test_framework.netutil import all_interfaces, addr_to_hex, get_bind_addrs, test_ipv6_local
from test_framework.test_framework import BitcoinTestFramework, SkipTest
+from test_framework.test_node import ErrorMatch
from test_framework.util import assert_equal, assert_raises_rpc_error, get_rpc_proxy, rpc_port, rpc_url
class RPCBindTest(BitcoinTestFramework):
@@ -45,6 +46,19 @@ class RPCBindTest(BitcoinTestFramework):
assert_equal(set(get_bind_addrs(pid)), set(expected))
self.stop_nodes()
+ def run_invalid_bind_test(self, allow_ips, addresses):
+ '''
+ Attempt to start a node with requested rpcallowip and rpcbind
+ parameters, expecting that the node will fail.
+ '''
+ self.log.info(f'Invalid bind test for {addresses}')
+ base_args = ['-disablewallet', '-nolisten']
+ if allow_ips:
+ base_args += ['-rpcallowip=' + x for x in allow_ips]
+ init_error = 'Error' # generic error will be adjusted in next commit
+ for addr in addresses:
+ self.nodes[0].assert_start_raises_init_error(base_args + [f'-rpcbind={addr}'], init_error, ErrorMatch.PARTIAL_REGEX)
+
def run_allowip_test(self, allow_ips, rpchost, rpcport):
'''
Start a node with rpcallow IP, and request getnetworkinfo
@@ -84,6 +98,10 @@ class RPCBindTest(BitcoinTestFramework):
if not self.options.run_nonloopback:
self._run_loopback_tests()
+ if self.options.run_ipv4:
+ self.run_invalid_bind_test(['127.0.0.1'], ['127.0.0.1:notaport', '127.0.0.1:-18443', '127.0.0.1:0', '127.0.0.1:65536'])
+ if self.options.run_ipv6:
+ self.run_invalid_bind_test(['[::1]'], ['[::1]:notaport', '[::1]:-18443', '[::1]:0', '[::1]:65536'])
if not self.options.run_ipv4 and not self.options.run_ipv6:
self._run_nonloopback_tests()