aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_invalid_messages.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/p2p_invalid_messages.py')
-rwxr-xr-xtest/functional/p2p_invalid_messages.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py
index 759f111e69..eaecaeeb36 100755
--- a/test/functional/p2p_invalid_messages.py
+++ b/test/functional/p2p_invalid_messages.py
@@ -8,7 +8,11 @@ import struct
import sys
from test_framework import messages
-from test_framework.mininode import P2PDataStore, NetworkThread
+from test_framework.mininode import (
+ NetworkThread,
+ P2PDataStore,
+ P2PInterface,
+)
from test_framework.test_framework import BitcoinTestFramework
@@ -47,6 +51,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
self.test_checksum()
self.test_size()
self.test_command()
+ self.test_large_inv()
node = self.nodes[0]
self.node = node
@@ -198,6 +203,19 @@ class InvalidMessagesTest(BitcoinTestFramework):
conn.sync_with_ping(timeout=1)
self.nodes[0].disconnect_p2ps()
+ def test_large_inv(self):
+ conn = self.nodes[0].add_p2p_connection(P2PInterface())
+ with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=4 (0 -> 20): message inv size() = 50001']):
+ msg = messages.msg_inv([messages.CInv(1, 1)] * 50001)
+ conn.send_and_ping(msg)
+ with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=4 (20 -> 40): message getdata size() = 50001']):
+ msg = messages.msg_getdata([messages.CInv(1, 1)] * 50001)
+ conn.send_and_ping(msg)
+ with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=4 (40 -> 60): headers message size = 2001']):
+ msg = messages.msg_headers([messages.CBlockHeader()] * 2001)
+ conn.send_and_ping(msg)
+ self.nodes[0].disconnect_p2ps()
+
def _tweak_msg_data_size(self, message, wrong_size):
"""
Return a raw message based on another message but with an incorrect data size in