Skip to content

Commit f8d8eb5

Browse files
committed
test: add addr-fetch timeout connection coverage in p2p_addrfetch.py
1 parent 9321086 commit f8d8eb5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/functional/p2p_addrfetch.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,20 @@ def run_test(self):
5959
peer.wait_for_disconnect(timeout=5)
6060

6161
self.log.info("Check timeout for addr-fetch peer that does not send addrs")
62-
peer = node.add_outbound_p2p_connection(P2PInterface(), p2p_idx=1, connection_type="addr-fetch")
63-
node.setmocktime(int(time.time()) + 301) # Timeout: 5 minutes
62+
peer_id = 1
63+
peer = node.add_outbound_p2p_connection(P2PInterface(), p2p_idx=peer_id, connection_type="addr-fetch")
64+
65+
time_now = int(time.time())
66+
self.assert_getpeerinfo(peer_ids=[peer_id])
67+
68+
# Expect addr-fetch peer connection to be maintained up to 5 minutes.
69+
node.setmocktime(time_now + 295)
70+
self.assert_getpeerinfo(peer_ids=[peer_id])
71+
72+
# Expect addr-fetch peer connection to be disconnected after 5 minutes.
73+
node.setmocktime(time_now + 301)
6474
peer.wait_for_disconnect(timeout=5)
75+
self.assert_getpeerinfo(peer_ids=[])
6576

6677

6778
if __name__ == '__main__':

0 commit comments

Comments
 (0)