|
6 | 6 | Test ports handling for I2P hosts |
7 | 7 | """ |
8 | 8 |
|
9 | | -import re |
10 | 9 |
|
11 | 10 | from test_framework.test_framework import BitcoinTestFramework |
12 | 11 |
|
| 12 | +PROXY = "127.0.0.1:60000" |
13 | 13 |
|
14 | 14 | class I2PPorts(BitcoinTestFramework): |
15 | 15 | def set_test_params(self): |
16 | 16 | self.num_nodes = 1 |
17 | 17 | # The test assumes that an I2P SAM proxy is not listening here. |
18 | | - self.extra_args = [["-i2psam=127.0.0.1:60000"]] |
| 18 | + self.extra_args = [[f"-i2psam={PROXY}"]] |
19 | 19 |
|
20 | 20 | def run_test(self): |
21 | 21 | node = self.nodes[0] |
22 | 22 |
|
23 | 23 | self.log.info("Ensure we don't try to connect if port!=0") |
24 | 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") |
| 25 | + with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}, connection refused due to arbitrary port 8333"]): |
| 26 | + node.addnode(node=addr, command="onetry") |
35 | 27 |
|
36 | 28 | self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy") |
37 | 29 | addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0" |
38 | | - with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}"]): |
| 30 | + with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {PROXY}"]): |
39 | 31 | node.addnode(node=addr, command="onetry") |
40 | 32 |
|
41 | 33 |
|
|
0 commit comments