|
9 | 9 | import random
|
10 | 10 | import time
|
11 | 11 |
|
| 12 | +from test_framework.netutil import UNREACHABLE_PROXY_ARG |
12 | 13 | from test_framework.test_framework import BitcoinTestFramework
|
13 | 14 |
|
14 | 15 | ADD_NEXT_SEEDNODE = 10
|
|
17 | 18 | class P2PSeedNodes(BitcoinTestFramework):
|
18 | 19 | def set_test_params(self):
|
19 | 20 | self.num_nodes = 1
|
| 21 | + # Specify a non-working proxy to make sure no actual connections to random IPs are attempted. |
| 22 | + self.extra_args = [[UNREACHABLE_PROXY_ARG]] |
20 | 23 | self.disable_autoconnect = False
|
21 | 24 |
|
22 | 25 | def test_no_seednode(self):
|
23 | 26 | self.log.info("Check that if no seednode is provided, the node proceeds as usual (without waiting)")
|
24 | 27 | with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["Empty addrman, adding seednode", f"Couldn't connect to peers from addrman after {ADD_NEXT_SEEDNODE} seconds. Adding seednode"], timeout=ADD_NEXT_SEEDNODE):
|
25 |
| - self.restart_node(0) |
| 28 | + self.restart_node(0, extra_args=self.nodes[0].extra_args) |
26 | 29 |
|
27 | 30 | def test_seednode_empty_addrman(self):
|
28 |
| - seed_node = "0.0.0.1" |
| 31 | + seed_node = "25.0.0.1" |
29 | 32 | self.log.info("Check that the seednode is immediately added on bootstrap on an empty addrman")
|
30 | 33 | with self.nodes[0].assert_debug_log(expected_msgs=[f"Empty addrman, adding seednode ({seed_node}) to addrfetch"], timeout=ADD_NEXT_SEEDNODE):
|
31 |
| - self.restart_node(0, extra_args=[f'-seednode={seed_node}']) |
| 34 | + self.restart_node(0, extra_args=self.nodes[0].extra_args + [f'-seednode={seed_node}']) |
32 | 35 |
|
33 | 36 | def test_seednode_non_empty_addrman(self):
|
34 | 37 | self.log.info("Check that if addrman is non-empty, seednodes are queried with a delay")
|
35 |
| - seed_node = "0.0.0.2" |
| 38 | + seed_node = "25.0.0.2" |
36 | 39 | node = self.nodes[0]
|
37 | 40 | # Fill the addrman with unreachable nodes
|
38 | 41 | for i in range(10):
|
39 | 42 | ip = f"{random.randrange(128,169)}.{random.randrange(1,255)}.{random.randrange(1,255)}.{random.randrange(1,255)}"
|
40 | 43 | port = 8333 + i
|
41 | 44 | node.addpeeraddress(ip, port)
|
42 | 45 |
|
43 |
| - # Restart the node so seednode is processed again. Specify a non-working proxy to make sure no actual connections to random IPs are attempted. |
| 46 | + # Restart the node so seednode is processed again. |
44 | 47 | with node.assert_debug_log(expected_msgs=["trying v1 connection"], timeout=ADD_NEXT_SEEDNODE):
|
45 |
| - self.restart_node(0, extra_args=[f'-seednode={seed_node}', '-proxy=127.0.0.1:1']) |
| 48 | + self.restart_node(0, extra_args=self.nodes[0].extra_args + [f'-seednode={seed_node}']) |
46 | 49 |
|
47 | 50 | with node.assert_debug_log(expected_msgs=[f"Couldn't connect to peers from addrman after {ADD_NEXT_SEEDNODE} seconds. Adding seednode ({seed_node}) to addrfetch"], unexpected_msgs=["Empty addrman, adding seednode"], timeout=ADD_NEXT_SEEDNODE * 1.5):
|
48 | 51 | node.setmocktime(int(time.time()) + ADD_NEXT_SEEDNODE + 1)
|
|
0 commit comments