File tree Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def run_test(self):
54
54
# p2p_conns[2] will test resetting the counters
55
55
p2p_conns = []
56
56
57
- for i in range (3 ):
57
+ for _ in range (3 ):
58
58
p2p_conns .append (self .nodes [0 ].add_p2p_connection (TestNode ()))
59
59
60
60
NetworkThread ().start () # Start up network handling in another thread
@@ -139,8 +139,7 @@ def run_test(self):
139
139
140
140
self .log .info ("Peer 2 able to download old block" )
141
141
142
- for i in range (3 ):
143
- self .nodes [0 ].disconnect_p2p ()
142
+ self .nodes [0 ].disconnect_p2ps ()
144
143
145
144
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
146
145
self .log .info ("Restarting nodes with -whitelist=127.0.0.1" )
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ def run_test(self):
206
206
# The node should have requested the blocks at some point, so
207
207
# disconnect/reconnect first
208
208
209
- self .nodes [0 ].disconnect_p2p ()
209
+ self .nodes [0 ].disconnect_p2ps ()
210
210
test_node = self .nodes [0 ].add_p2p_connection (NodeConnCB ())
211
211
212
212
test_node .wait_for_verack ()
@@ -291,7 +291,7 @@ def run_test(self):
291
291
except AssertionError :
292
292
test_node .wait_for_disconnect ()
293
293
294
- self .nodes [0 ].disconnect_p2p ()
294
+ self .nodes [0 ].disconnect_p2ps ()
295
295
test_node = self .nodes [0 ].add_p2p_connection (NodeConnCB ())
296
296
297
297
NetworkThread ().start () # Start up network handling in another thread
Original file line number Diff line number Diff line change @@ -126,8 +126,7 @@ def run_test(self):
126
126
assert not unsupported_service_bit5_node .connected
127
127
assert not unsupported_service_bit7_node .connected
128
128
129
- for _ in range (5 ):
130
- self .nodes [0 ].disconnect_p2p ()
129
+ self .nodes [0 ].disconnect_p2ps ()
131
130
132
131
# Wait until all connections are closed
133
132
wait_until (lambda : len (self .nodes [0 ].getpeerinfo ()) == 0 )
Original file line number Diff line number Diff line change @@ -182,13 +182,14 @@ def p2p(self):
182
182
assert self .p2ps , "No p2p connection"
183
183
return self .p2ps [0 ]
184
184
185
- def disconnect_p2p (self , index = 0 ):
186
- """Close the p2p connection to the node."""
187
- # Connection could have already been closed by other end. Calling disconnect_p2p()
188
- # on an already disconnected p2p connection is not an error.
189
- if self .p2ps [index ].connection is not None :
190
- self .p2ps [index ].connection .disconnect_node ()
191
- del self .p2ps [index ]
185
+ def disconnect_p2ps (self ):
186
+ """Close all p2p connections to the node."""
187
+ for p in self .p2ps :
188
+ # Connection could have already been closed by other end.
189
+ if p .connection is not None :
190
+ p .connection .disconnect_node ()
191
+ self .p2ps = []
192
+
192
193
193
194
class TestNodeCLI ():
194
195
"""Interface to bitcoin-cli for an individual node"""
You can’t perform that action at this time.
0 commit comments