#!/usr/bin/env python3 # Copyright (c) 2019 The Bitcoin developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """ABC Invalid Message Test Test that invalid messages get rejected and/or ban the sender as expected for each case. """ import struct from test_framework.messages import NODE_NETWORK, msg_version from test_framework.mininode import ( MAGIC_BYTES, mininode_lock, msg_ping, network_thread_start, P2PInterface, ) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import wait_until def msg_bad_checksum(connection, original_message): message_data = bytearray(connection.format_message(original_message)) data = original_message.serialize() i = 0 i += len(MAGIC_BYTES[connection.network]) i += 12 i += len(struct.pack("