@@ -579,14 +579,14 @@ def run_test(self):
579579 while b47 .sha256 < target :
580580 b47 .nNonce += 1
581581 b47 .rehash ()
582- self .sync_blocks ([b47 ], False , request_block = False )
582+ self .sync_blocks ([b47 ], False , force_send = True , reject_reason = 'high-hash' )
583583
584584 self .log .info ("Reject a block with a timestamp >2 hours in the future" )
585585 self .move_tip (44 )
586586 b48 = self .next_block (48 , solve = False )
587587 b48 .nTime = int (time .time ()) + 60 * 60 * 3
588588 b48 .solve ()
589- self .sync_blocks ([b48 ], False , request_block = False )
589+ self .sync_blocks ([b48 ], False , force_send = True , reject_reason = 'time-too-new' )
590590
591591 self .log .info ("Reject a block with invalid merkle hash" )
592592 self .move_tip (44 )
@@ -600,7 +600,7 @@ def run_test(self):
600600 b50 = self .next_block (50 )
601601 b50 .nBits = b50 .nBits - 1
602602 b50 .solve ()
603- self .sync_blocks ([b50 ], False , request_block = False , reconnect = True )
603+ self .sync_blocks ([b50 ], False , force_send = True , reject_reason = 'bad-diffbits' , reconnect = True )
604604
605605 self .log .info ("Reject a block with two coinbase transactions" )
606606 self .move_tip (44 )
@@ -630,7 +630,7 @@ def run_test(self):
630630 b54 = self .next_block (54 , spend = out [15 ])
631631 b54 .nTime = b35 .nTime - 1
632632 b54 .solve ()
633- self .sync_blocks ([b54 ], False , request_block = False )
633+ self .sync_blocks ([b54 ], False , force_send = True , reject_reason = 'time-too-old' )
634634
635635 # valid timestamp
636636 self .move_tip (53 )
@@ -1078,11 +1078,11 @@ def run_test(self):
10781078
10791079 self .move_tip (77 )
10801080 b80 = self .next_block (80 , spend = out [25 ])
1081- self .sync_blocks ([b80 ], False , request_block = False )
1081+ self .sync_blocks ([b80 ], False , force_send = True )
10821082 self .save_spendable_output ()
10831083
10841084 b81 = self .next_block (81 , spend = out [26 ])
1085- self .sync_blocks ([b81 ], False , request_block = False ) # other chain is same length
1085+ self .sync_blocks ([b81 ], False , force_send = True ) # other chain is same length
10861086 self .save_spendable_output ()
10871087
10881088 b82 = self .next_block (82 , spend = out [27 ])
@@ -1189,7 +1189,7 @@ def run_test(self):
11891189 blocks2 = []
11901190 for i in range (89 , LARGE_REORG_SIZE + 89 ):
11911191 blocks2 .append (self .next_block ("alt" + str (i )))
1192- self .sync_blocks (blocks2 , False , request_block = False )
1192+ self .sync_blocks (blocks2 , False , force_send = True )
11931193
11941194 # extend alt chain to trigger re-org
11951195 block = self .next_block ("alt" + str (chain1_tip + 1 ))
@@ -1198,7 +1198,7 @@ def run_test(self):
11981198 # ... and re-org back to the first chain
11991199 self .move_tip (chain1_tip )
12001200 block = self .next_block (chain1_tip + 1 )
1201- self .sync_blocks ([block ], False , request_block = False )
1201+ self .sync_blocks ([block ], False , force_send = True )
12021202 block = self .next_block (chain1_tip + 2 )
12031203 self .sync_blocks ([block ], True , timeout = 180 )
12041204
@@ -1309,14 +1309,15 @@ def reconnect_p2p(self):
13091309 self .nodes [0 ].disconnect_p2ps ()
13101310 self .bootstrap_p2p ()
13111311
1312- def sync_blocks (self , blocks , success = True , reject_reason = None , request_block = True , reconnect = False , timeout = 60 ):
1312+ def sync_blocks (self , blocks , success = True , reject_reason = None , force_send = False , reconnect = False , timeout = 60 ):
13131313 """Sends blocks to test node. Syncs and verifies that tip has advanced to most recent block.
13141314
13151315 Call with success = False if the tip shouldn't advance to the most recent block."""
1316- self .nodes [0 ].p2p .send_blocks_and_test (blocks , self .nodes [0 ], success = success , reject_reason = reject_reason , request_block = request_block , timeout = timeout , expect_disconnect = reconnect )
1316+ self .nodes [0 ].p2p .send_blocks_and_test (blocks , self .nodes [0 ], success = success , reject_reason = reject_reason , force_send = force_send , timeout = timeout , expect_disconnect = reconnect )
13171317
13181318 if reconnect :
13191319 self .reconnect_p2p ()
13201320
1321+
13211322if __name__ == '__main__' :
13221323 FullBlockTest ().main ()
0 commit comments