Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-invalid-message.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
class InvalidMessageTest(BitcoinTestFramework): | class InvalidMessageTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = False | self.setup_clean_chain = False | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
def run_test(self): | def run_test(self): | ||||
# Try to connect to a node using an invalid checksum on version message | # Try to connect to a node using an invalid checksum on version message | ||||
bad_interface = BadVersionP2PInterface() | bad_interface = BadVersionP2PInterface() | ||||
self.nodes[0].add_p2p_connection(bad_interface) | self.nodes[0].add_p2p_connection( | ||||
bad_interface, send_version=False, wait_for_verack=False) | |||||
# Also connect to a node with a valid version message | # Also connect to a node with a valid version message | ||||
interface = P2PInterface() | interface = P2PInterface() | ||||
# Node with valid version message should connect successfully | |||||
connection = self.nodes[1].add_p2p_connection(interface) | connection = self.nodes[1].add_p2p_connection(interface) | ||||
# The invalid version message should cause a disconnect on the first | # The invalid version message should cause a disconnect on the first | ||||
# connection because we are now banned | # connection because we are now banned | ||||
bad_interface.wait_for_disconnect() | bad_interface.wait_for_disconnect() | ||||
# Node with valid version message should connect successfully | |||||
connection.wait_for_verack() | |||||
# Create a valid message | # Create a valid message | ||||
valid_message = msg_ping(interface.ping_counter) | valid_message = msg_ping(interface.ping_counter) | ||||
def wait_for_ping(): | def wait_for_ping(): | ||||
def check_ping(): | def check_ping(): | ||||
if not interface.last_message.get("pong"): | if not interface.last_message.get("pong"): | ||||
return False | return False | ||||
return interface.last_message["pong"].nonce == interface.ping_counter | return interface.last_message["pong"].nonce == interface.ping_counter | ||||
Show All 18 Lines |