test: Check that invalid peer traffic is accounted for
This commit is contained in:
parent
fae243f0cb
commit
faa94cb167
1 changed files with 6 additions and 3 deletions
|
@ -22,12 +22,11 @@ from test_framework.p2p import (
|
||||||
P2PInterface,
|
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
|
||||||
assert_equal,
|
|
||||||
)
|
|
||||||
|
|
||||||
VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 # Account for the 5-byte length prefix
|
VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 # Account for the 5-byte length prefix
|
||||||
|
|
||||||
|
|
||||||
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."""
|
||||||
|
|
||||||
|
@ -100,6 +99,8 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||||
msg = msg[:cut_len] + b'\xff' * 4 + msg[cut_len + 4:]
|
msg = msg[:cut_len] + b'\xff' * 4 + msg[cut_len + 4:]
|
||||||
conn.send_raw_message(msg)
|
conn.send_raw_message(msg)
|
||||||
conn.sync_with_ping(timeout=1)
|
conn.sync_with_ping(timeout=1)
|
||||||
|
# Check that traffic is accounted for (24 bytes header + 2 bytes payload)
|
||||||
|
assert_equal(self.nodes[0].getpeerinfo()[0]['bytesrecv_per_msg']['*other*'], 26)
|
||||||
self.nodes[0].disconnect_p2ps()
|
self.nodes[0].disconnect_p2ps()
|
||||||
|
|
||||||
def test_size(self):
|
def test_size(self):
|
||||||
|
@ -123,6 +124,8 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||||
msg = msg[:7] + b'\x00' + msg[7 + 1:]
|
msg = msg[:7] + b'\x00' + msg[7 + 1:]
|
||||||
conn.send_raw_message(msg)
|
conn.send_raw_message(msg)
|
||||||
conn.sync_with_ping(timeout=1)
|
conn.sync_with_ping(timeout=1)
|
||||||
|
# Check that traffic is accounted for (24 bytes header + 2 bytes payload)
|
||||||
|
assert_equal(self.nodes[0].getpeerinfo()[0]['bytesrecv_per_msg']['*other*'], 26)
|
||||||
self.nodes[0].disconnect_p2ps()
|
self.nodes[0].disconnect_p2ps()
|
||||||
|
|
||||||
def test_oversized_msg(self, msg, size):
|
def test_oversized_msg(self, msg, size):
|
||||||
|
|
Loading…
Reference in a new issue