mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-03 01:09:14 +01:00
p2p: allow p2ptimeout to be configurable, speed up slow test
This commit is contained in:
committed by
Zain Iqbal Allarakhia
parent
384967f311
commit
8042bbfbf0
@@ -14,11 +14,11 @@
|
||||
- Wait 1 second
|
||||
- Assert that we're connected
|
||||
- Send a ping to no_verack_node and no_version_node
|
||||
- Wait 30 seconds
|
||||
- Wait 1 second
|
||||
- Assert that we're still connected
|
||||
- Send a ping to no_verack_node and no_version_node
|
||||
- Wait 31 seconds
|
||||
- Assert that we're no longer connected (timeout to receive version/verack is 60 seconds)
|
||||
- Wait 2 seconds
|
||||
- Assert that we're no longer connected (timeout to receive version/verack is 3 seconds)
|
||||
"""
|
||||
|
||||
from time import sleep
|
||||
@@ -36,6 +36,8 @@ class TimeoutsTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 1
|
||||
# set timeout to receive version/verack to 3 seconds
|
||||
self.extra_args = [["-peertimeout=3"]]
|
||||
|
||||
def run_test(self):
|
||||
# Setup the p2p connections
|
||||
@@ -52,7 +54,7 @@ class TimeoutsTest(BitcoinTestFramework):
|
||||
no_verack_node.send_message(msg_ping())
|
||||
no_version_node.send_message(msg_ping())
|
||||
|
||||
sleep(30)
|
||||
sleep(1)
|
||||
|
||||
assert "version" in no_verack_node.last_message
|
||||
|
||||
@@ -63,11 +65,17 @@ class TimeoutsTest(BitcoinTestFramework):
|
||||
no_verack_node.send_message(msg_ping())
|
||||
no_version_node.send_message(msg_ping())
|
||||
|
||||
sleep(31)
|
||||
expected_timeout_logs = [
|
||||
"version handshake timeout from 0",
|
||||
"socket no message in first 3 seconds, 1 0 from 1",
|
||||
"socket no message in first 3 seconds, 0 0 from 2",
|
||||
]
|
||||
|
||||
assert not no_verack_node.is_connected
|
||||
assert not no_version_node.is_connected
|
||||
assert not no_send_node.is_connected
|
||||
with self.nodes[0].assert_debug_log(expected_msgs=expected_timeout_logs):
|
||||
sleep(2)
|
||||
assert not no_verack_node.is_connected
|
||||
assert not no_version_node.is_connected
|
||||
assert not no_send_node.is_connected
|
||||
|
||||
if __name__ == '__main__':
|
||||
TimeoutsTest().main()
|
||||
|
||||
Reference in New Issue
Block a user