diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-09-28 10:15:27 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-09-28 10:14:00 +0200 |
commit | faa94cb1675d8bd511eb593176cd07aa59465225 (patch) | |
tree | 450331f07907d3bb3db427647d687cdf508144c5 | |
parent | fae243f0cb92b5648d07d0a5033e2f4de862ae99 (diff) |
test: Check that invalid peer traffic is accounted for
-rwxr-xr-x | test/functional/p2p_invalid_messages.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py index 3a88532195..bdcefe2ff5 100755 --- a/test/functional/p2p_invalid_messages.py +++ b/test/functional/p2p_invalid_messages.py @@ -22,12 +22,11 @@ from test_framework.p2p import ( P2PInterface, ) from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import ( - assert_equal, -) +from test_framework.util import assert_equal VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 # Account for the 5-byte length prefix + class msg_unrecognized: """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:] conn.send_raw_message(msg) 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() def test_size(self): @@ -123,6 +124,8 @@ class InvalidMessagesTest(BitcoinTestFramework): msg = msg[:7] + b'\x00' + msg[7 + 1:] conn.send_raw_message(msg) 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() def test_oversized_msg(self, msg, size): |