Skip to content

Commit c642b08

Browse files
committed
test: Log when the garbage is actually sent to transport layer
Currently, we log the number of bytes of garbage when it is generated. The log is a better fit for when the garbage actually gets sent to the transport layer.
1 parent 86cca2c commit c642b08

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

test/functional/test_framework/p2p.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def connection_made(self, transport):
223223
# send the initial handshake immediately
224224
if self.supports_v2_p2p and self.v2_state.initiating and not self.v2_state.tried_v2_handshake:
225225
send_handshake_bytes = self.v2_state.initiate_v2_handshake()
226+
logger.debug(f"sending {len(self.v2_state.sent_garbage)} bytes of garbage data")
226227
self.send_raw_message(send_handshake_bytes)
227228
# for v1 outbound connections, send version message immediately after opening
228229
# (for v2 outbound connections, send it after the initial v2 handshake)
@@ -262,6 +263,7 @@ def _on_data_v2_handshake(self):
262263
self.v2_state = None
263264
return
264265
elif send_handshake_bytes:
266+
logger.debug(f"sending {len(self.v2_state.sent_garbage)} bytes of garbage data")
265267
self.send_raw_message(send_handshake_bytes)
266268
elif send_handshake_bytes == b"":
267269
return # only after send_handshake_bytes are sent can `complete_handshake()` be done

test/functional/test_framework/v2_p2p.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Class for v2 P2P protocol (see BIP 324)"""
66

7-
import logging
87
import random
98

109
from .crypto.bip324_cipher import FSChaCha20Poly1305
@@ -14,7 +13,6 @@
1413
from .key import TaggedHash
1514
from .messages import MAGIC_BYTES
1615

17-
logger = logging.getLogger("TestFramework.v2_p2p")
1816

1917
CHACHA20POLY1305_EXPANSION = 16
2018
HEADER_LEN = 1
@@ -116,7 +114,6 @@ def generate_keypair_and_garbage(self):
116114
self.privkey_ours, self.ellswift_ours = ellswift_create()
117115
garbage_len = random.randrange(MAX_GARBAGE_LEN + 1)
118116
self.sent_garbage = random.randbytes(garbage_len)
119-
logger.debug(f"sending {garbage_len} bytes of garbage data")
120117
return self.ellswift_ours + self.sent_garbage
121118

122119
def initiate_v2_handshake(self):

0 commit comments

Comments
 (0)