@@ -306,7 +306,7 @@ def blocksonly_mode_tests(self):
306
306
307
307
self .nodes [0 ].disconnect_p2ps ()
308
308
309
- def send_addrs_and_test_rate_limiting (self , peer , no_relay , new_addrs , total_addrs ):
309
+ def send_addrs_and_test_rate_limiting (self , peer , no_relay , * , new_addrs , total_addrs ):
310
310
"""Send an addr message and check that the number of addresses processed and rate-limited is as expected"""
311
311
312
312
peer .send_and_ping (self .setup_rand_addr_msg (new_addrs ))
@@ -324,41 +324,41 @@ def send_addrs_and_test_rate_limiting(self, peer, no_relay, new_addrs, total_add
324
324
assert_equal (addrs_rate_limited , max (0 , total_addrs - peer .tokens ))
325
325
326
326
def rate_limit_tests (self ):
327
-
328
327
self .restart_node (0 , [])
329
328
330
- for contype , no_relay in [("outbound-full-relay" , False ), ("block-relay-only" , True ), ("inbound" , False )]:
331
- self .log .info (f'Test rate limiting of addr processing for { contype } peers' )
332
- if contype == "inbound" :
329
+ for conn_type , no_relay in [("outbound-full-relay" , False ), ("block-relay-only" , True ), ("inbound" , False )]:
330
+ self .log .info (f'Test rate limiting of addr processing for { conn_type } peers' )
331
+ if conn_type == "inbound" :
333
332
peer = self .nodes [0 ].add_p2p_connection (AddrReceiver ())
334
333
else :
335
- peer = self .nodes [0 ].add_outbound_p2p_connection (AddrReceiver (), p2p_idx = 0 , connection_type = contype )
334
+ peer = self .nodes [0 ].add_outbound_p2p_connection (AddrReceiver (), p2p_idx = 0 , connection_type = conn_type )
336
335
337
336
# Send 600 addresses. For all but the block-relay-only peer this should result in addresses being processed.
338
- self .send_addrs_and_test_rate_limiting (peer , no_relay , 600 , 600 )
337
+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 600 , total_addrs = 600 )
339
338
340
339
# Send 600 more addresses. For the outbound-full-relay peer (which we send a GETADDR, and thus will
341
340
# process up to 1001 incoming addresses), this means more addresses will be processed.
342
- self .send_addrs_and_test_rate_limiting (peer , no_relay , 600 , 1200 )
341
+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 600 , total_addrs = 1200 )
343
342
344
343
# Send 10 more. As we reached the processing limit for all nodes, no more addresses should be procesesd.
345
- self .send_addrs_and_test_rate_limiting (peer , no_relay , 10 , 1210 )
344
+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 10 , total_addrs = 1210 )
346
345
347
346
# Advance the time by 100 seconds, permitting the processing of 10 more addresses.
348
347
# Send 200 and verify that 10 are processed.
349
348
self .bump_mocktime (100 )
350
349
peer .increment_tokens (10 )
351
350
352
- self .send_addrs_and_test_rate_limiting (peer , no_relay , 200 , 1410 )
351
+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 200 , total_addrs = 1410 )
353
352
354
353
# Advance the time by 1000 seconds, permitting the processing of 100 more addresses.
355
354
# Send 200 and verify that 100 are processed.
356
355
self .bump_mocktime (1000 )
357
356
peer .increment_tokens (100 )
358
357
359
- self .send_addrs_and_test_rate_limiting (peer , no_relay , 200 , 1610 )
358
+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 200 , total_addrs = 1610 )
360
359
361
360
self .nodes [0 ].disconnect_p2ps ()
362
361
362
+
363
363
if __name__ == '__main__' :
364
364
AddrTest ().main ()
0 commit comments