test: Check that disconnection happens when >4095 garbage bytes is sent

This test type is represented using EXCESS_GARBAGE.
This commit is contained in:
stratospher committed 2024-06-21 19:37:13 +05:30
1 parent e075fd131d
commit e351576862
2 files changed
+35 -3

No files matched your search

+3 -2
View File
@@ -109,10 +109,11 @@ class EncryptedP2PState:
# Responding, place their public key encoding first.
return TaggedHash("bip324_ellswift_xonly_ecdh", ellswift_theirs + ellswift_ours + ecdh_point_x32)
def generate_keypair_and_garbage(self):
def generate_keypair_and_garbage(self, garbage_len=None):
"""Generates ellswift keypair and 4095 bytes garbage at max"""
self.privkey_ours, self.ellswift_ours = ellswift_create()
garbage_len = random.randrange(MAX_GARBAGE_LEN + 1)
if garbage_len is None:
garbage_len = random.randrange(MAX_GARBAGE_LEN + 1)
self.sent_garbage = random.randbytes(garbage_len)
return self.ellswift_ours + self.sent_garbage