aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-06-23 10:57:28 +0200
committerVasil Dimov <vd@FreeBSD.org>2021-07-09 11:19:37 +0200
commit41cda9d075ebcab1dbb950160ebe9d0ba7b5745e (patch)
tree3090758b4a26ef20c6229d73228d7e535772bfb9 /test/functional
parent4f432bd738c420512a86a51ab3e00323f396b89e (diff)
test: ensure I2P ports are handled as expected
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/p2p_i2p_ports.py43
-rwxr-xr-xtest/functional/test_runner.py1
2 files changed, 44 insertions, 0 deletions
diff --git a/test/functional/p2p_i2p_ports.py b/test/functional/p2p_i2p_ports.py
new file mode 100755
index 0000000000..13188b9305
--- /dev/null
+++ b/test/functional/p2p_i2p_ports.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# Copyright (c) 2021-2021 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""
+Test ports handling for I2P hosts
+"""
+
+import re
+
+from test_framework.test_framework import BitcoinTestFramework
+
+
+class I2PPorts(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 1
+ # The test assumes that an I2P SAM proxy is not listening here.
+ self.extra_args = [["-i2psam=127.0.0.1:60000"]]
+
+ def run_test(self):
+ node = self.nodes[0]
+
+ self.log.info("Ensure we don't try to connect if port!=0")
+ addr = "zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:8333"
+ raised = False
+ try:
+ with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
+ node.addnode(node=addr, command="onetry")
+ except AssertionError as e:
+ raised = True
+ if not re.search(r"Expected messages .* does not partially match log", str(e)):
+ raise AssertionError(f"Assertion raised as expected, but with an unexpected message: {str(e)}")
+ if not raised:
+ raise AssertionError("Assertion should have been raised")
+
+ self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy")
+ addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"
+ with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
+ node.addnode(node=addr, command="onetry")
+
+
+if __name__ == '__main__':
+ I2PPorts().main()
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index ad1acd2e2f..fbd9d6028a 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -291,6 +291,7 @@ BASE_SCRIPTS = [
'p2p_permissions.py',
'feature_blocksdir.py',
'wallet_startup.py',
+ 'p2p_i2p_ports.py',
'feature_config_args.py',
'feature_settings.py',
'rpc_getdescriptorinfo.py',