mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
test: Use msg_generic in p2p_ping.py
This commit is contained in:
@@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from test_framework.messages import msg_pong
|
from test_framework.messages import (
|
||||||
|
msg_pong,
|
||||||
|
msg_generic,
|
||||||
|
)
|
||||||
from test_framework.p2p import P2PInterface
|
from test_framework.p2p import P2PInterface
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
@@ -20,11 +23,6 @@ PING_INTERVAL = 2 * 60
|
|||||||
TIMEOUT_INTERVAL = 20 * 60
|
TIMEOUT_INTERVAL = 20 * 60
|
||||||
|
|
||||||
|
|
||||||
class msg_pong_corrupt(msg_pong):
|
|
||||||
def serialize(self):
|
|
||||||
return b""
|
|
||||||
|
|
||||||
|
|
||||||
class NodeNoPong(P2PInterface):
|
class NodeNoPong(P2PInterface):
|
||||||
def on_ping(self, message):
|
def on_ping(self, message):
|
||||||
pass
|
pass
|
||||||
@@ -60,7 +58,7 @@ class PingPongTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info('Reply without nonce cancels ping')
|
self.log.info('Reply without nonce cancels ping')
|
||||||
with self.nodes[0].assert_debug_log(['pong peer=0: Short payload']):
|
with self.nodes[0].assert_debug_log(['pong peer=0: Short payload']):
|
||||||
no_pong_node.send_and_ping(msg_pong_corrupt())
|
no_pong_node.send_and_ping(msg_generic(b"pong", b""))
|
||||||
self.check_peer_info(pingtime=None, minping=None, pingwait=None)
|
self.check_peer_info(pingtime=None, minping=None, pingwait=None)
|
||||||
|
|
||||||
self.log.info('Reply without ping')
|
self.log.info('Reply without ping')
|
||||||
|
|||||||
@@ -1374,8 +1374,8 @@ class msg_block:
|
|||||||
return "msg_block(block=%s)" % (repr(self.block))
|
return "msg_block(block=%s)" % (repr(self.block))
|
||||||
|
|
||||||
|
|
||||||
# for cases where a user needs tighter control over what is sent over the wire
|
# Generic type to control the raw bytes sent over the wire.
|
||||||
# note that the user must supply the name of the msgtype, and the data
|
# The msgtype and the data must be provided.
|
||||||
class msg_generic:
|
class msg_generic:
|
||||||
__slots__ = ("msgtype", "data")
|
__slots__ = ("msgtype", "data")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user