@@ -311,7 +311,7 @@ def blocksonly_mode_tests(self):
311311
312312 self .nodes [0 ].disconnect_p2ps ()
313313
314- def send_addrs_and_test_rate_limiting (self , peer , no_relay , new_addrs , total_addrs ):
314+ def send_addrs_and_test_rate_limiting (self , peer , no_relay , * , new_addrs , total_addrs ):
315315 """Send an addr message and check that the number of addresses processed and rate-limited is as expected"""
316316
317317 peer .send_and_ping (self .setup_rand_addr_msg (new_addrs ))
@@ -329,45 +329,45 @@ def send_addrs_and_test_rate_limiting(self, peer, no_relay, new_addrs, total_add
329329 assert_equal (addrs_rate_limited , max (0 , total_addrs - peer .tokens ))
330330
331331 def rate_limit_tests (self ):
332-
333332 self .mocktime = int (time .time ())
334333 self .restart_node (0 , [])
335334 self .nodes [0 ].setmocktime (self .mocktime )
336335
337- for contype , no_relay in [("outbound-full-relay" , False ), ("block-relay-only" , True ), ("inbound" , False )]:
338- self .log .info (f'Test rate limiting of addr processing for { contype } peers' )
339- if contype == "inbound" :
336+ for conn_type , no_relay in [("outbound-full-relay" , False ), ("block-relay-only" , True ), ("inbound" , False )]:
337+ self .log .info (f'Test rate limiting of addr processing for { conn_type } peers' )
338+ if conn_type == "inbound" :
340339 peer = self .nodes [0 ].add_p2p_connection (AddrReceiver ())
341340 else :
342- peer = self .nodes [0 ].add_outbound_p2p_connection (AddrReceiver (), p2p_idx = 0 , connection_type = contype )
341+ peer = self .nodes [0 ].add_outbound_p2p_connection (AddrReceiver (), p2p_idx = 0 , connection_type = conn_type )
343342
344343 # Send 600 addresses. For all but the block-relay-only peer this should result in addresses being processed.
345- self .send_addrs_and_test_rate_limiting (peer , no_relay , 600 , 600 )
344+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 600 , total_addrs = 600 )
346345
347346 # Send 600 more addresses. For the outbound-full-relay peer (which we send a GETADDR, and thus will
348347 # process up to 1001 incoming addresses), this means more addresses will be processed.
349- self .send_addrs_and_test_rate_limiting (peer , no_relay , 600 , 1200 )
348+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 600 , total_addrs = 1200 )
350349
351350 # Send 10 more. As we reached the processing limit for all nodes, no more addresses should be procesesd.
352- self .send_addrs_and_test_rate_limiting (peer , no_relay , 10 , 1210 )
351+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 10 , total_addrs = 1210 )
353352
354353 # Advance the time by 100 seconds, permitting the processing of 10 more addresses.
355354 # Send 200 and verify that 10 are processed.
356355 self .mocktime += 100
357356 self .nodes [0 ].setmocktime (self .mocktime )
358357 peer .increment_tokens (10 )
359358
360- self .send_addrs_and_test_rate_limiting (peer , no_relay , 200 , 1410 )
359+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 200 , total_addrs = 1410 )
361360
362361 # Advance the time by 1000 seconds, permitting the processing of 100 more addresses.
363362 # Send 200 and verify that 100 are processed.
364363 self .mocktime += 1000
365364 self .nodes [0 ].setmocktime (self .mocktime )
366365 peer .increment_tokens (100 )
367366
368- self .send_addrs_and_test_rate_limiting (peer , no_relay , 200 , 1610 )
367+ self .send_addrs_and_test_rate_limiting (peer , no_relay , new_addrs = 200 , total_addrs = 1610 )
369368
370369 self .nodes [0 ].disconnect_p2ps ()
371370
371+
372372if __name__ == '__main__' :
373373 AddrTest ().main ()
0 commit comments