Skip to content

Commit ab9b064

Browse files
vasildhebasto
authored andcommitted
test: ensure I2P ports are handled as expected
1 parent a8d051e commit ab9b064

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

test/functional/p2p_i2p_ports.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2021-2021 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""
6+
Test ports handling for I2P hosts
7+
"""
8+
9+
import re
10+
11+
from test_framework.test_framework import BitcoinTestFramework
12+
13+
14+
class I2PPorts(BitcoinTestFramework):
15+
def set_test_params(self):
16+
self.num_nodes = 1
17+
# The test assumes that an I2P SAM proxy is not listening here.
18+
self.extra_args = [["-i2psam=127.0.0.1:60000"]]
19+
20+
def run_test(self):
21+
node = self.nodes[0]
22+
23+
self.log.info("Ensure we don't try to connect if port!=0")
24+
addr = "zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:8333"
25+
raised = False
26+
try:
27+
with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
28+
node.addnode(node=addr, command="onetry")
29+
except AssertionError as e:
30+
raised = True
31+
if not re.search(r"Expected messages .* does not partially match log", str(e)):
32+
raise AssertionError(f"Assertion raised as expected, but with an unexpected message: {str(e)}")
33+
if not raised:
34+
raise AssertionError("Assertion should have been raised")
35+
36+
self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy")
37+
addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"
38+
with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]):
39+
node.addnode(node=addr, command="onetry")
40+
41+
42+
if __name__ == '__main__':
43+
I2PPorts().main()

test/functional/test_runner.py

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@
293293
'p2p_permissions.py',
294294
'feature_blocksdir.py',
295295
'wallet_startup.py',
296+
'p2p_i2p_ports.py',
296297
'feature_config_args.py',
297298
'feature_settings.py',
298299
'rpc_getdescriptorinfo.py',

0 commit comments

Comments
 (0)