Skip to content

Commit d768f15

Browse files
mrbandrewsTheBlueMatt
authored andcommitted
[qa] Make comptool push blocks instead of relying on inv-fetch
1 parent 9f554e0 commit d768f15

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

qa/rpc-tests/test_framework/comptool.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def send_getheaders(self):
111111
m.locator = self.block_store.get_locator(self.bestblockhash)
112112
self.conn.send_message(m)
113113

114+
def send_header(self, header):
115+
m = msg_headers()
116+
m.headers.append(header)
117+
self.conn.send_message(m)
118+
114119
# This assumes BIP31
115120
def send_ping(self, nonce):
116121
self.pingMap[nonce] = True
@@ -345,15 +350,25 @@ def run(self):
345350
# Either send inv's to each node and sync, or add
346351
# to invqueue for later inv'ing.
347352
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
350363
if (not self.check_results(tip, outcome)):
351364
raise AssertionError("Test failed at test %d" % test_number)
352365
else:
353366
invqueue.append(CInv(2, block.sha256))
354367
elif isinstance(b_or_t, CBlockHeader):
355368
block_header = b_or_t
356369
self.block_store.add_header(block_header)
370+
[ c.cb.send_header(block_header) for c in self.connections ]
371+
357372
else: # Tx test runner
358373
assert(isinstance(b_or_t, CTransaction))
359374
tx = b_or_t

0 commit comments

Comments
 (0)