@@ -111,6 +111,11 @@ def send_getheaders(self):
111
111
m .locator = self .block_store .get_locator (self .bestblockhash )
112
112
self .conn .send_message (m )
113
113
114
+ def send_header (self , header ):
115
+ m = msg_headers ()
116
+ m .headers .append (header )
117
+ self .conn .send_message (m )
118
+
114
119
# This assumes BIP31
115
120
def send_ping (self , nonce ):
116
121
self .pingMap [nonce ] = True
@@ -345,15 +350,25 @@ def run(self):
345
350
# Either send inv's to each node and sync, or add
346
351
# to invqueue for later inv'ing.
347
352
if (test_instance .sync_every_block ):
348
- [ c .cb .send_inv (block ) for c in self .connections ]
349
- self .sync_blocks (block .sha256 , 1 )
353
+ # if we expect success, send inv and sync every block
354
+ # if we expect failure, just push the block and see what happens.
355
+ if outcome == True :
356
+ [ c .cb .send_inv (block ) for c in self .connections ]
357
+ self .sync_blocks (block .sha256 , 1 )
358
+ else :
359
+ [ c .send_message (msg_block (block )) for c in self .connections ]
360
+ [ c .cb .send_ping (self .ping_counter ) for c in self .connections ]
361
+ self .wait_for_pings (self .ping_counter )
362
+ self .ping_counter += 1
350
363
if (not self .check_results (tip , outcome )):
351
364
raise AssertionError ("Test failed at test %d" % test_number )
352
365
else :
353
366
invqueue .append (CInv (2 , block .sha256 ))
354
367
elif isinstance (b_or_t , CBlockHeader ):
355
368
block_header = b_or_t
356
369
self .block_store .add_header (block_header )
370
+ [ c .cb .send_header (block_header ) for c in self .connections ]
371
+
357
372
else : # Tx test runner
358
373
assert (isinstance (b_or_t , CTransaction ))
359
374
tx = b_or_t
0 commit comments