Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_timeouts.py
Show All 18 Lines | |||||
- Send a ping to no_verack_node and no_version_node | - Send a ping to no_verack_node and no_version_node | ||||
- Wait 31 seconds | - Wait 31 seconds | ||||
- Assert that we're no longer connected (timeout to receive version/verack is 60 seconds) | - Assert that we're no longer connected (timeout to receive version/verack is 60 seconds) | ||||
""" | """ | ||||
from time import sleep | from time import sleep | ||||
from test_framework.messages import msg_ping | from test_framework.messages import msg_ping | ||||
from test_framework.mininode import network_thread_start, P2PInterface | from test_framework.mininode import P2PInterface | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
class TestP2PConn(P2PInterface): | class TestP2PConn(P2PInterface): | ||||
def on_version(self, message): | def on_version(self, message): | ||||
# Don't send a verack in response | # Don't send a verack in response | ||||
pass | pass | ||||
class TimeoutsTest(BitcoinTestFramework): | class TimeoutsTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
def run_test(self): | def run_test(self): | ||||
# Setup the p2p connections and start up the network thread. | # Setup the p2p connections | ||||
no_verack_node = self.nodes[0].add_p2p_connection(TestP2PConn()) | no_verack_node = self.nodes[0].add_p2p_connection(TestP2PConn()) | ||||
no_version_node = self.nodes[0].add_p2p_connection( | no_version_node = self.nodes[0].add_p2p_connection( | ||||
TestP2PConn(), send_version=False) | TestP2PConn(), send_version=False) | ||||
no_send_node = self.nodes[0].add_p2p_connection( | no_send_node = self.nodes[0].add_p2p_connection( | ||||
TestP2PConn(), send_version=False) | TestP2PConn(), send_version=False) | ||||
network_thread_start() | |||||
sleep(1) | sleep(1) | ||||
assert no_verack_node.is_connected | assert no_verack_node.is_connected | ||||
assert no_version_node.is_connected | assert no_version_node.is_connected | ||||
assert no_send_node.is_connected | assert no_send_node.is_connected | ||||
no_verack_node.send_message(msg_ping()) | no_verack_node.send_message(msg_ping()) | ||||
no_version_node.send_message(msg_ping()) | no_version_node.send_message(msg_ping()) | ||||
Show All 21 Lines |