Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_invalid_messages.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2019 The Bitcoin Core developers | # Copyright (c) 2015-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test node responses to invalid network messages.""" | """Test node responses to invalid network messages.""" | ||||
import struct | import struct | ||||
import time | import time | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
CBlockHeader, | |||||
CInv, | |||||
MAX_HEADERS_RESULTS, | MAX_HEADERS_RESULTS, | ||||
MAX_INV_SIZE, | MAX_INV_SIZE, | ||||
MAX_PROTOCOL_MESSAGE_LENGTH, | MAX_PROTOCOL_MESSAGE_LENGTH, | ||||
MSG_TX, | |||||
CBlockHeader, | |||||
CInv, | |||||
msg_avahello, | msg_avahello, | ||||
msg_avapoll, | msg_avapoll, | ||||
msg_avaresponse, | msg_avaresponse, | ||||
msg_getdata, | msg_getdata, | ||||
msg_headers, | msg_headers, | ||||
msg_inv, | msg_inv, | ||||
msg_ping, | msg_ping, | ||||
MSG_TX, | |||||
ser_string, | ser_string, | ||||
) | ) | ||||
from test_framework.p2p import ( | from test_framework.p2p import P2PDataStore, P2PInterface | ||||
P2PDataStore, | |||||
P2PInterface, | |||||
) | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import assert_equal, hex_str_to_bytes, wait_until | ||||
hex_str_to_bytes, | |||||
assert_equal, | |||||
wait_until, | |||||
) | |||||
# Account for the 5-byte length prefix | # Account for the 5-byte length prefix | ||||
VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 | VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 | ||||
class msg_unrecognized: | class msg_unrecognized: | ||||
"""Nonsensical message. Modeled after similar types in test_framework.messages.""" | """Nonsensical message. Modeled after similar types in test_framework.messages.""" | ||||
▲ Show 20 Lines • Show All 282 Lines • Show Last 20 Lines |