Browse Source

[tests] clarify assertions in getblocktemplate test

0.15
John Newbery 8 years ago
parent
commit
f82c709fbe
  1. 8
      test/functional/getblocktemplate_proposals.py

8
test/functional/getblocktemplate_proposals.py

@ -64,8 +64,7 @@ def template_to_hex(tmpl, txlist):
def assert_template(node, tmpl, txlist, expect): def assert_template(node, tmpl, txlist, expect):
rsp = node.getblocktemplate({'data': template_to_hex(tmpl, txlist), 'mode': 'proposal'}) rsp = node.getblocktemplate({'data': template_to_hex(tmpl, txlist), 'mode': 'proposal'})
if rsp != expect: assert_equal(rsp, expect)
raise AssertionError('unexpected: %s' % (rsp,))
class GetBlockTemplateProposalTest(BitcoinTestFramework): class GetBlockTemplateProposalTest(BitcoinTestFramework):
@ -88,7 +87,7 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework):
txlist = [bytearray(coinbase_tx.serialize())] txlist = [bytearray(coinbase_tx.serialize())]
self.log.info("getblocktemplate: Test capability advertised") self.log.info("getblocktemplate: Test capability advertised")
assert('proposal' in tmpl['capabilities']) assert 'proposal' in tmpl['capabilities']
self.log.info("getblocktemplate: Test bad input hash for coinbase transaction") self.log.info("getblocktemplate: Test bad input hash for coinbase transaction")
txlist[0][4 + 1] += 1 txlist[0][4 + 1] += 1
@ -131,8 +130,7 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework):
rawtmpl = template_to_bytearray(tmpl, txlist) rawtmpl = template_to_bytearray(tmpl, txlist)
rawtmpl[4 + 32] = (rawtmpl[4 + 32] + 1) % 0x100 rawtmpl[4 + 32] = (rawtmpl[4 + 32] + 1) % 0x100
rsp = node.getblocktemplate({'data': b2x(rawtmpl), 'mode': 'proposal'}) rsp = node.getblocktemplate({'data': b2x(rawtmpl), 'mode': 'proposal'})
if rsp != 'bad-txnmrklroot': assert_equal(rsp, 'bad-txnmrklroot')
raise AssertionError('unexpected: %s' % (rsp,))
self.log.info("getblocktemplate: Test bad timestamps") self.log.info("getblocktemplate: Test bad timestamps")
realtime = tmpl['curtime'] realtime = tmpl['curtime']

Loading…
Cancel
Save