@@ -195,7 +195,7 @@ def run_test(self):
195
195
daily_buffer = 144 * 1000000
196
196
max_bytes_available = max_bytes_per_day - daily_buffer
197
197
success_count = max_bytes_available / old_block_size
198
-
198
+
199
199
# 144MB will be reserved for relaying new blocks, so expect this to
200
200
# succeed for ~70 tries.
201
201
for i in xrange (success_count ):
@@ -228,7 +228,7 @@ def run_test(self):
228
228
test_nodes [1 ].send_message (getdata_request )
229
229
test_nodes [1 ].wait_for_disconnect ()
230
230
assert_equal (len (self .nodes [0 ].getpeerinfo ()), 1 )
231
-
231
+
232
232
print "Peer 1 disconnected after trying to download old block"
233
233
234
234
print "Advancing system time on node to clear counters..."
@@ -245,5 +245,38 @@ def run_test(self):
245
245
246
246
[c .disconnect_node () for c in connections ]
247
247
248
+ #stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
249
+ print "Restarting nodes with -whitelist=127.0.0.1"
250
+ stop_node (self .nodes [0 ], 0 )
251
+ self .nodes [0 ] = start_node (0 , self .options .tmpdir , ["-debug" , "-whitelist=127.0.0.1" , "-maxuploadtarget=1" , "-blockmaxsize=999000" ])
252
+
253
+ #recreate/reconnect 3 test nodes
254
+ test_nodes = []
255
+ connections = []
256
+
257
+ for i in xrange (3 ):
258
+ test_nodes .append (TestNode ())
259
+ connections .append (NodeConn ('127.0.0.1' , p2p_port (0 ), self .nodes [0 ], test_nodes [i ]))
260
+ test_nodes [i ].add_connection (connections [i ])
261
+
262
+ NetworkThread ().start () # Start up network handling in another thread
263
+ [x .wait_for_verack () for x in test_nodes ]
264
+
265
+ #retrieve 20 blocks which should be enough to break the 1MB limit
266
+ getdata_request .inv = [CInv (2 , big_new_block )]
267
+ for i in xrange (20 ):
268
+ test_nodes [1 ].send_message (getdata_request )
269
+ test_nodes [1 ].sync_with_ping ()
270
+ assert_equal (test_nodes [1 ].block_receive_map [big_new_block ], i + 1 )
271
+
272
+ getdata_request .inv = [CInv (2 , big_old_block )]
273
+ test_nodes [1 ].send_message (getdata_request )
274
+ test_nodes [1 ].wait_for_disconnect ()
275
+ assert_equal (len (self .nodes [0 ].getpeerinfo ()), 3 ) #node is still connected because of the whitelist
276
+
277
+ print "Peer 1 still connected after trying to download old block (whitelisted)"
278
+
279
+ [c .disconnect_node () for c in connections ]
280
+
248
281
if __name__ == '__main__' :
249
282
MaxUploadTest ().main ()
0 commit comments