@@ -63,23 +63,20 @@ def on_cmpctblock(self, message): self.bad_message(message)
63
63
def on_getblocktxn (self , message ): self .bad_message (message )
64
64
def on_blocktxn (self , message ): self .bad_message (message )
65
65
66
+
66
67
# Node that never sends a version. We'll use this to send a bunch of messages
67
68
# anyway, and eventually get disconnected.
68
69
class CNodeNoVersionMisbehavior (CLazyNode ):
69
- # Send enough veracks without a message to reach the peer discouragement
70
- # threshold. This should get us disconnected. NOTE: implementation-specific
71
- # test; update if our discouragement policy for peer misbehavior changes.
72
- def on_open (self ):
73
- super ().on_open ()
74
- for _ in range (DISCOURAGEMENT_THRESHOLD ):
75
- self .send_message (msg_verack ())
70
+ pass
71
+
76
72
77
73
# Node that never sends a version. This one just sits idle and hopes to receive
78
74
# any message (it shouldn't!)
79
75
class CNodeNoVersionIdle (CLazyNode ):
80
76
def __init__ (self ):
81
77
super ().__init__ ()
82
78
79
+
83
80
# Node that sends a version but not a verack.
84
81
class CNodeNoVerackIdle (CLazyNode ):
85
82
def __init__ (self ):
@@ -114,6 +111,11 @@ def run_test(self):
114
111
no_version_idlenode = self .nodes [0 ].add_p2p_connection (CNodeNoVersionIdle (), send_version = False , wait_for_verack = False )
115
112
no_verack_idlenode = self .nodes [0 ].add_p2p_connection (CNodeNoVerackIdle (), wait_for_verack = False )
116
113
114
+ # Send enough veracks without a message to reach the peer discouragement
115
+ # threshold. This should get us disconnected.
116
+ for _ in range (DISCOURAGEMENT_THRESHOLD ):
117
+ no_version_disconnect_node .send_message (msg_verack ())
118
+
117
119
# Wait until we got the verack in response to the version. Though, don't wait for the other node to receive the
118
120
# verack, since we never sent one
119
121
no_verack_idlenode .wait_for_verack ()
@@ -153,7 +155,6 @@ def run_test(self):
153
155
p2p_old_node = self .nodes [0 ].add_p2p_connection (P2PInterface (), send_version = False , wait_for_verack = False )
154
156
old_version_msg = msg_version ()
155
157
old_version_msg .nVersion = 31799
156
- wait_until (lambda : p2p_old_node .is_connected )
157
158
with self .nodes [0 ].assert_debug_log (['peer=4 using obsolete version 31799; disconnecting' ]):
158
159
p2p_old_node .send_message (old_version_msg )
159
160
p2p_old_node .wait_for_disconnect ()
0 commit comments