Skip to content

Commit 60b7ef5

Browse files
committed
MERGE-FIX: mining_basic.py: Remove magic constants, make sure serialized header deserializes
1 parent c5a93c0 commit 60b7ef5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/functional/mining_basic.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def run_test(self):
108108

109109
self.log.info("getblocktemplate: Test bad tx count")
110110
# The tx count is immediately after the block header
111-
TX_COUNT_OFFSET = 80+4 # height is extra 4
111+
TX_COUNT_OFFSET = len(CBlockHeader().serialize())
112112
bad_block_sn = bytearray(block.serialize())
113113
assert_equal(bad_block_sn[TX_COUNT_OFFSET], 1)
114114
bad_block_sn[TX_COUNT_OFFSET] += 1
@@ -138,9 +138,11 @@ def run_test(self):
138138
assert_template(node, bad_block, 'inconclusive-not-best-prevblk')
139139

140140
self.log.info('submitheader tests')
141-
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='xx' * 80))
142-
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='ff' * 78))
143-
assert_raises_rpc_error(-25, 'Must submit previous header', lambda: node.submitheader(hexdata='ff' * 80))
141+
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='xx' * TX_COUNT_OFFSET))
142+
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='ff' * (TX_COUNT_OFFSET-2)))
143+
import pdb
144+
pdb.set_trace()
145+
assert_raises_rpc_error(-25, 'Must submit previous header', lambda: node.submitheader(hexdata=super(CBlock, bad_block).serialize().hex()))
144146

145147
block.solve()
146148

0 commit comments

Comments
 (0)