|
|
|
@ -111,6 +111,11 @@ class TestNode(NodeConnCB):
|
|
|
|
|
m.locator = self.block_store.get_locator(self.bestblockhash)
|
|
|
|
|
self.conn.send_message(m)
|
|
|
|
|
|
|
|
|
|
def send_header(self, header):
|
|
|
|
|
m = msg_headers()
|
|
|
|
|
m.headers.append(header)
|
|
|
|
|
self.conn.send_message(m)
|
|
|
|
|
|
|
|
|
|
# This assumes BIP31
|
|
|
|
|
def send_ping(self, nonce):
|
|
|
|
|
self.pingMap[nonce] = True
|
|
|
|
@ -345,8 +350,16 @@ class TestManager(object):
|
|
|
|
|
# Either send inv's to each node and sync, or add
|
|
|
|
|
# to invqueue for later inv'ing.
|
|
|
|
|
if (test_instance.sync_every_block):
|
|
|
|
|
[ c.cb.send_inv(block) for c in self.connections ]
|
|
|
|
|
self.sync_blocks(block.sha256, 1)
|
|
|
|
|
# if we expect success, send inv and sync every block
|
|
|
|
|
# if we expect failure, just push the block and see what happens.
|
|
|
|
|
if outcome == True:
|
|
|
|
|
[ c.cb.send_inv(block) for c in self.connections ]
|
|
|
|
|
self.sync_blocks(block.sha256, 1)
|
|
|
|
|
else:
|
|
|
|
|
[ c.send_message(msg_block(block)) for c in self.connections ]
|
|
|
|
|
[ c.cb.send_ping(self.ping_counter) for c in self.connections ]
|
|
|
|
|
self.wait_for_pings(self.ping_counter)
|
|
|
|
|
self.ping_counter += 1
|
|
|
|
|
if (not self.check_results(tip, outcome)):
|
|
|
|
|
raise AssertionError("Test failed at test %d" % test_number)
|
|
|
|
|
else:
|
|
|
|
@ -354,6 +367,8 @@ class TestManager(object):
|
|
|
|
|
elif isinstance(b_or_t, CBlockHeader):
|
|
|
|
|
block_header = b_or_t
|
|
|
|
|
self.block_store.add_header(block_header)
|
|
|
|
|
[ c.cb.send_header(block_header) for c in self.connections ]
|
|
|
|
|
|
|
|
|
|
else: # Tx test runner
|
|
|
|
|
assert(isinstance(b_or_t, CTransaction))
|
|
|
|
|
tx = b_or_t
|
|
|
|
|