Skip to content

Commit a763497

Browse files
committed
Merge bitcoin/bitcoin#32834: test: Use msg_generic in p2p_ping.py
fa3f100 test: Use msg_generic in p2p_ping.py (MarcoFalke) Pull request description: It seems odd to derive `msg_pong_corrupt` from `msg_pong`, but then overwrite the serialize method, when one can just directly use `msg_generic` to pass the raw bytes to send over the wire. Fix that by using `msg_generic`. This also serves as a regression test against the fix in commit 3348057. (Can be tested by reverting that commit to observe a failure) ACKs for top commit: dergoegge: utACK fa3f100 theStack: ACK fa3f100 Tree-SHA512: 53d7d2289f27646fdf7d3b86c53e8e707fa4ca4b006d232850f9dc27409d79b7abe1dece95ccef429d4b52c6a89579c0cc5c0ee37046375c3c0310a2d6f9ddd5
2 parents 3348057 + fa3f100 commit a763497

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

test/functional/p2p_ping.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import time
99

10-
from test_framework.messages import msg_pong
10+
from test_framework.messages import (
11+
msg_pong,
12+
msg_generic,
13+
)
1114
from test_framework.p2p import P2PInterface
1215
from test_framework.test_framework import BitcoinTestFramework
1316
from test_framework.util import (
@@ -20,11 +23,6 @@
2023
TIMEOUT_INTERVAL = 20 * 60
2124

2225

23-
class msg_pong_corrupt(msg_pong):
24-
def serialize(self):
25-
return b""
26-
27-
2826
class NodeNoPong(P2PInterface):
2927
def on_ping(self, message):
3028
pass
@@ -60,7 +58,7 @@ def run_test(self):
6058

6159
self.log.info('Reply without nonce cancels ping')
6260
with self.nodes[0].assert_debug_log(['pong peer=0: Short payload']):
63-
no_pong_node.send_and_ping(msg_pong_corrupt())
61+
no_pong_node.send_and_ping(msg_generic(b"pong", b""))
6462
self.check_peer_info(pingtime=None, minping=None, pingwait=None)
6563

6664
self.log.info('Reply without ping')

test/functional/test_framework/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ def __repr__(self):
13741374
return "msg_block(block=%s)" % (repr(self.block))
13751375

13761376

1377-
# for cases where a user needs tighter control over what is sent over the wire
1378-
# note that the user must supply the name of the msgtype, and the data
1377+
# Generic type to control the raw bytes sent over the wire.
1378+
# The msgtype and the data must be provided.
13791379
class msg_generic:
13801380
__slots__ = ("msgtype", "data")
13811381

0 commit comments

Comments
 (0)