Skip to content

Commit bb97b1f

Browse files
committed
test: fix intermittent timeout in p2p_seednodes.py
On some CI runs, the timer in ThreadOpenConnection was only started *after* the mocktime was set. Fix this by waiting for the first connection attempt, which happens after the timer was started. Also convert some comments into log messages/add a log, so that the test isn't completely silent.
1 parent ffe4261 commit bb97b1f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/functional/p2p_seednode.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ def set_test_params(self):
2020
self.disable_autoconnect = False
2121

2222
def test_no_seednode(self):
23-
# Check that if no seednode is provided, the node proceeds as usual (without waiting)
23+
self.log.info("Check that if no seednode is provided, the node proceeds as usual (without waiting)")
2424
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):
2525
self.restart_node(0)
2626

2727
def test_seednode_empty_addrman(self):
2828
seed_node = "0.0.0.1"
29-
# Check that the seednode is added to m_addr_fetches on bootstrap on an empty addrman
29+
self.log.info("Check that the seednode is immediately added on bootstrap on an empty addrman")
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

3333
def test_seednode_addrman_unreachable_peers(self):
34+
self.log.info("Check that if addrman is non-empty, seednodes are queried with a delay")
3435
seed_node = "0.0.0.2"
3536
node = self.nodes[0]
3637
# Fill the addrman with unreachable nodes
@@ -40,8 +41,10 @@ def test_seednode_addrman_unreachable_peers(self):
4041
node.addpeeraddress(ip, port)
4142

4243
# Restart the node so seednode is processed again
43-
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):
44+
with node.assert_debug_log(expected_msgs=["trying v1 connection"], timeout=ADD_NEXT_SEEDNODE):
4445
self.restart_node(0, extra_args=[f'-seednode={seed_node}'])
46+
47+
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):
4548
node.setmocktime(int(time.time()) + ADD_NEXT_SEEDNODE + 1)
4649

4750
def run_test(self):
@@ -52,4 +55,3 @@ def run_test(self):
5255

5356
if __name__ == '__main__':
5457
P2PSeedNodes(__file__).main()
55-

0 commit comments

Comments
 (0)