aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-04-11 15:09:19 -0400
committerJohn Newbery <john@johnnewbery.com>2017-06-27 15:51:37 +0100
commit66c570a38eb21153599f0478adc5a17ca9821a52 (patch)
treeb670e8162e38b8b7d1fe2b8c2db22a9d38ddc113 /test
parent38b38cd2d1a8db8d4bf5bd88e1cbd14d640c73c7 (diff)
[tests] Don't build the coinbase manually in getblocktemplate test
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/getblocktemplate_proposals.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/functional/getblocktemplate_proposals.py b/test/functional/getblocktemplate_proposals.py
index 6fd5279b8e..82a82d01f2 100755
--- a/test/functional/getblocktemplate_proposals.py
+++ b/test/functional/getblocktemplate_proposals.py
@@ -8,6 +8,7 @@ from binascii import a2b_hex, b2a_hex
from hashlib import sha256
from struct import pack
+from test_framework.blocktools import create_coinbase
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@@ -78,13 +79,13 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework):
# Mine a block to leave initial block download
node.generate(1)
tmpl = node.getblocktemplate()
- if 'coinbasetxn' not in tmpl:
- rawcoinbase = encodeUNum(tmpl['height'])
- rawcoinbase += b'\x01-'
- hexcoinbase = b2x(rawcoinbase)
- hexoutval = b2x(pack('<Q', tmpl['coinbasevalue']))
- tmpl['coinbasetxn'] = {'data': '01000000' + '01' + '0000000000000000000000000000000000000000000000000000000000000000ffffffff' + ('%02x' % (len(rawcoinbase),)) + hexcoinbase + 'fffffffe' + '01' + hexoutval + '00' + '00000000'}
- txlist = list(bytearray(a2b_hex(a['data'])) for a in (tmpl['coinbasetxn'],) + tuple(tmpl['transactions']))
+ assert 'coinbasetxn' not in tmpl
+
+ coinbase_tx = create_coinbase(height=int(tmpl["height"]) + 1)
+ # sequence numbers must not be max for nLockTime to have effect
+ coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
+ tmpl['coinbasetxn'] = {'data': coinbase_tx.serialize()}
+ txlist = [bytearray(coinbase_tx.serialize())]
self.log.info("getblocktemplate: Test capability advertised")
assert('proposal' in tmpl['capabilities'])