Skip to content

Commit ff1e7b8

Browse files
committed
Move size limits to module-global
As well, this renames those variables to match PEP8 and this clears up the comment relating to VALID_DATA_LIMIT. Admittedly, this commit is mainly to make the following ones cleaner.
1 parent 57890ab commit ff1e7b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/functional/p2p_invalid_messages.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
)
2424
from test_framework.test_framework import BitcoinTestFramework
2525

26+
MSG_LIMIT = 4 * 1000 * 1000 # 4MB, per MAX_PROTOCOL_MESSAGE_LENGTH
27+
VALID_DATA_LIMIT = MSG_LIMIT - 5 # Account for the 5-byte length prefix
2628

2729
class msg_unrecognized:
2830
"""Nonsensical message. Modeled after similar types in test_framework.messages."""
@@ -61,17 +63,15 @@ def run_test(self):
6163
node.add_p2p_connection(P2PDataStore())
6264
conn2 = node.add_p2p_connection(P2PDataStore())
6365

64-
msg_limit = 4 * 1000 * 1000 # 4MB, per MAX_PROTOCOL_MESSAGE_LENGTH
65-
valid_data_limit = msg_limit - 5 # Account for the 4-byte length prefix
6666

6767
#
6868
# 0.
6969
#
7070
# Send as large a message as is valid, ensure we aren't disconnected but
7171
# also can't exhaust resources.
7272
#
73-
msg_at_size = msg_unrecognized(str_data="b" * valid_data_limit)
74-
assert len(msg_at_size.serialize()) == msg_limit
73+
msg_at_size = msg_unrecognized(str_data="b" * VALID_DATA_LIMIT)
74+
assert len(msg_at_size.serialize()) == MSG_LIMIT
7575

7676
self.log.info("Sending a bunch of large, junk messages to test memory exhaustion. May take a bit...")
7777

0 commit comments

Comments
 (0)