|
|
@ -21,6 +21,10 @@ from .mininode import * |
|
|
|
from .blockstore import BlockStore, TxStore |
|
|
|
from .blockstore import BlockStore, TxStore |
|
|
|
from .util import p2p_port |
|
|
|
from .util import p2p_port |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger=logging.getLogger("TestFramework.comptool") |
|
|
|
|
|
|
|
|
|
|
|
global mininode_lock |
|
|
|
global mininode_lock |
|
|
|
|
|
|
|
|
|
|
|
class RejectResult(object): |
|
|
|
class RejectResult(object): |
|
|
@ -209,7 +213,6 @@ class TestManager(object): |
|
|
|
|
|
|
|
|
|
|
|
# --> error if not requested |
|
|
|
# --> error if not requested |
|
|
|
if not wait_until(blocks_requested, attempts=20*num_blocks): |
|
|
|
if not wait_until(blocks_requested, attempts=20*num_blocks): |
|
|
|
# print [ c.cb.block_request_map for c in self.connections ] |
|
|
|
|
|
|
|
raise AssertionError("Not all nodes requested block") |
|
|
|
raise AssertionError("Not all nodes requested block") |
|
|
|
|
|
|
|
|
|
|
|
# Send getheaders message |
|
|
|
# Send getheaders message |
|
|
@ -231,7 +234,6 @@ class TestManager(object): |
|
|
|
|
|
|
|
|
|
|
|
# --> error if not requested |
|
|
|
# --> error if not requested |
|
|
|
if not wait_until(transaction_requested, attempts=20*num_events): |
|
|
|
if not wait_until(transaction_requested, attempts=20*num_events): |
|
|
|
# print [ c.cb.tx_request_map for c in self.connections ] |
|
|
|
|
|
|
|
raise AssertionError("Not all nodes requested transaction") |
|
|
|
raise AssertionError("Not all nodes requested transaction") |
|
|
|
|
|
|
|
|
|
|
|
# Get the mempool |
|
|
|
# Get the mempool |
|
|
@ -258,13 +260,12 @@ class TestManager(object): |
|
|
|
if c.cb.bestblockhash == blockhash: |
|
|
|
if c.cb.bestblockhash == blockhash: |
|
|
|
return False |
|
|
|
return False |
|
|
|
if blockhash not in c.cb.block_reject_map: |
|
|
|
if blockhash not in c.cb.block_reject_map: |
|
|
|
print('Block not in reject map: %064x' % (blockhash)) |
|
|
|
logger.error('Block not in reject map: %064x' % (blockhash)) |
|
|
|
return False |
|
|
|
return False |
|
|
|
if not outcome.match(c.cb.block_reject_map[blockhash]): |
|
|
|
if not outcome.match(c.cb.block_reject_map[blockhash]): |
|
|
|
print('Block rejected with %s instead of expected %s: %064x' % (c.cb.block_reject_map[blockhash], outcome, blockhash)) |
|
|
|
logger.error('Block rejected with %s instead of expected %s: %064x' % (c.cb.block_reject_map[blockhash], outcome, blockhash)) |
|
|
|
return False |
|
|
|
return False |
|
|
|
elif ((c.cb.bestblockhash == blockhash) != outcome): |
|
|
|
elif ((c.cb.bestblockhash == blockhash) != outcome): |
|
|
|
# print c.cb.bestblockhash, blockhash, outcome |
|
|
|
|
|
|
|
return False |
|
|
|
return False |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
@ -280,19 +281,17 @@ class TestManager(object): |
|
|
|
if outcome is None: |
|
|
|
if outcome is None: |
|
|
|
# Make sure the mempools agree with each other |
|
|
|
# Make sure the mempools agree with each other |
|
|
|
if c.cb.lastInv != self.connections[0].cb.lastInv: |
|
|
|
if c.cb.lastInv != self.connections[0].cb.lastInv: |
|
|
|
# print c.rpc.getrawmempool() |
|
|
|
|
|
|
|
return False |
|
|
|
return False |
|
|
|
elif isinstance(outcome, RejectResult): # Check that tx was rejected w/ code |
|
|
|
elif isinstance(outcome, RejectResult): # Check that tx was rejected w/ code |
|
|
|
if txhash in c.cb.lastInv: |
|
|
|
if txhash in c.cb.lastInv: |
|
|
|
return False |
|
|
|
return False |
|
|
|
if txhash not in c.cb.tx_reject_map: |
|
|
|
if txhash not in c.cb.tx_reject_map: |
|
|
|
print('Tx not in reject map: %064x' % (txhash)) |
|
|
|
logger.error('Tx not in reject map: %064x' % (txhash)) |
|
|
|
return False |
|
|
|
return False |
|
|
|
if not outcome.match(c.cb.tx_reject_map[txhash]): |
|
|
|
if not outcome.match(c.cb.tx_reject_map[txhash]): |
|
|
|
print('Tx rejected with %s instead of expected %s: %064x' % (c.cb.tx_reject_map[txhash], outcome, txhash)) |
|
|
|
logger.error('Tx rejected with %s instead of expected %s: %064x' % (c.cb.tx_reject_map[txhash], outcome, txhash)) |
|
|
|
return False |
|
|
|
return False |
|
|
|
elif ((txhash in c.cb.lastInv) != outcome): |
|
|
|
elif ((txhash in c.cb.lastInv) != outcome): |
|
|
|
# print c.rpc.getrawmempool(), c.cb.lastInv |
|
|
|
|
|
|
|
return False |
|
|
|
return False |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
@ -402,7 +401,7 @@ class TestManager(object): |
|
|
|
if (not self.check_mempool(tx.sha256, tx_outcome)): |
|
|
|
if (not self.check_mempool(tx.sha256, tx_outcome)): |
|
|
|
raise AssertionError("Mempool test failed at test %d" % test_number) |
|
|
|
raise AssertionError("Mempool test failed at test %d" % test_number) |
|
|
|
|
|
|
|
|
|
|
|
print("Test %d: PASS" % test_number, [ c.rpc.getblockcount() for c in self.connections ]) |
|
|
|
logger.info("Test %d: PASS" % test_number) |
|
|
|
test_number += 1 |
|
|
|
test_number += 1 |
|
|
|
|
|
|
|
|
|
|
|
[ c.disconnect_node() for c in self.connections ] |
|
|
|
[ c.disconnect_node() for c in self.connections ] |
|
|
|