Skip to content

Commit 6c9fe7b

Browse files
mzumsandevasild
andcommitted
test: Prevent connection attempts to random IPs in p2p_seednodes.py
These addrs aren't unreachable as the test claims. Specify a (non-working) proxy to make sure the connections fails even if the addr was reachable. Co-authored-by: Vasil Dimov <[email protected]>
1 parent bb97b1f commit 6c9fe7b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/functional/p2p_seednode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_seednode_empty_addrman(self):
3030
with self.nodes[0].assert_debug_log(expected_msgs=[f"Empty addrman, adding seednode ({seed_node}) to addrfetch"], timeout=ADD_NEXT_SEEDNODE):
3131
self.restart_node(0, extra_args=[f'-seednode={seed_node}'])
3232

33-
def test_seednode_addrman_unreachable_peers(self):
33+
def test_seednode_non_empty_addrman(self):
3434
self.log.info("Check that if addrman is non-empty, seednodes are queried with a delay")
3535
seed_node = "0.0.0.2"
3636
node = self.nodes[0]
@@ -40,17 +40,17 @@ def test_seednode_addrman_unreachable_peers(self):
4040
port = 8333 + i
4141
node.addpeeraddress(ip, port)
4242

43-
# Restart the node so seednode is processed again
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.
4444
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}'])
45+
self.restart_node(0, extra_args=[f'-seednode={seed_node}', '-proxy=127.0.0.1:1'])
4646

4747
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):
4848
node.setmocktime(int(time.time()) + ADD_NEXT_SEEDNODE + 1)
4949

5050
def run_test(self):
5151
self.test_no_seednode()
5252
self.test_seednode_empty_addrman()
53-
self.test_seednode_addrman_unreachable_peers()
53+
self.test_seednode_non_empty_addrman()
5454

5555

5656
if __name__ == '__main__':

0 commit comments

Comments
 (0)