diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-10-07 13:22:51 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-10-07 13:22:02 +0200 |
commit | fadf1186c899f45787a91c28120b0608bdc6c246 (patch) | |
tree | d7510161aa389dcbd0b7ed911cb5249c587f258a /test/functional/p2p_ping.py | |
parent | c0b6c96eee7c9e24b78935516225259e61cdabf7 (diff) |
p2p: Use mocktime for ping timeout
Diffstat (limited to 'test/functional/p2p_ping.py')
-rwxr-xr-x | test/functional/p2p_ping.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/functional/p2p_ping.py b/test/functional/p2p_ping.py index 888e986fba..d67e97acf7 100755 --- a/test/functional/p2p_ping.py +++ b/test/functional/p2p_ping.py @@ -30,11 +30,16 @@ class NodeNoPong(P2PInterface): pass +TIMEOUT_INTERVAL = 20 * 60 + + class PingPongTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 - self.extra_args = [['-peertimeout=3']] + # Set the peer connection timeout low. It does not matter for this + # test, as long as it is less than TIMEOUT_INTERVAL. + self.extra_args = [['-peertimeout=1']] def check_peer_info(self, *, pingtime, minping, pingwait): stats = self.nodes[0].getpeerinfo()[0] @@ -110,8 +115,11 @@ class PingPongTest(BitcoinTestFramework): self.nodes[0].ping() no_pong_node.wait_until(lambda: 'ping' in no_pong_node.last_message) with self.nodes[0].assert_debug_log(['ping timeout: 1201.000000s']): - self.mock_forward(20 * 60 + 1) - time.sleep(4) # peertimeout + 1 + self.mock_forward(TIMEOUT_INTERVAL // 2) + # Check that sending a ping does not prevent the disconnect + no_pong_node.sync_with_ping() + self.mock_forward(TIMEOUT_INTERVAL // 2 + 1) + no_pong_node.wait_for_disconnect() if __name__ == '__main__': |