Skip to content

Commit

Permalink
Use logging in test_framework/comptool.py
Browse files Browse the repository at this point in the history
  • Loading branch information
John Newbery committed Mar 9, 2017
1 parent ff19073 commit 38ad281
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions qa/rpc-tests/test_framework/comptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
from .blockstore import BlockStore, TxStore
from .util import p2p_port

import logging

logger=logging.getLogger("TestFramework.comptool")

global mininode_lock

class RejectResult(object):
Expand Down Expand Up @@ -209,7 +213,6 @@ def blocks_requested():

# --> error if not requested
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")

# Send getheaders message
Expand All @@ -231,7 +234,6 @@ def transaction_requested():

# --> error if not requested
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")

# Get the mempool
Expand All @@ -258,13 +260,12 @@ def check_results(self, blockhash, outcome):
if c.cb.bestblockhash == blockhash:
return False
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
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
elif ((c.cb.bestblockhash == blockhash) != outcome):
# print c.cb.bestblockhash, blockhash, outcome
return False
return True

Expand All @@ -280,19 +281,17 @@ def check_mempool(self, txhash, outcome):
if outcome is None:
# Make sure the mempools agree with each other
if c.cb.lastInv != self.connections[0].cb.lastInv:
# print c.rpc.getrawmempool()
return False
elif isinstance(outcome, RejectResult): # Check that tx was rejected w/ code
if txhash in c.cb.lastInv:
return False
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
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
elif ((txhash in c.cb.lastInv) != outcome):
# print c.rpc.getrawmempool(), c.cb.lastInv
return False
return True

Expand Down Expand Up @@ -402,7 +401,7 @@ def run(self):
if (not self.check_mempool(tx.sha256, tx_outcome)):
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

[ c.disconnect_node() for c in self.connections ]
Expand Down

0 comments on commit 38ad281

Please sign in to comment.