mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 11:11:15 +02:00
QA: Use GBT to get block versions correct
This commit is contained in:
@ -14,7 +14,7 @@ Generate 427 more blocks.
|
||||
"""
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import create_coinbase, create_block, create_transaction, add_witness_commitment
|
||||
from test_framework.blocktools import NORMAL_GBT_REQUEST_PARAMS, create_block, create_transaction, add_witness_commitment
|
||||
from test_framework.messages import CTransaction
|
||||
from test_framework.script import CScript
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
@ -37,14 +37,15 @@ def trueDummy(tx):
|
||||
class NULLDUMMYTest(BitcoinTestFramework):
|
||||
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
# Need two nodes only so GBT doesn't complain that it's not connected
|
||||
self.num_nodes = 2
|
||||
self.setup_clean_chain = True
|
||||
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
|
||||
# normal segwit activation here (and don't use the default always-on behaviour).
|
||||
self.extra_args = [[
|
||||
'-segwitheight=432',
|
||||
'-addresstype=legacy',
|
||||
]]
|
||||
]] * 2
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
@ -61,7 +62,6 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
||||
coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0])
|
||||
self.nodes[0].generate(427) # Block 429
|
||||
self.lastblockhash = self.nodes[0].getbestblockhash()
|
||||
self.tip = int("0x" + self.lastblockhash, 0)
|
||||
self.lastblockheight = 429
|
||||
self.lastblocktime = int(time.time()) + 429
|
||||
|
||||
@ -102,8 +102,10 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
||||
self.block_submit(self.nodes[0], test6txs, True, True)
|
||||
|
||||
def block_submit(self, node, txs, witness=False, accept=False):
|
||||
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1)
|
||||
block.nVersion = 4
|
||||
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||
assert_equal(tmpl['previousblockhash'], self.lastblockhash)
|
||||
assert_equal(tmpl['height'], self.lastblockheight + 1)
|
||||
block = create_block(tmpl=tmpl, ntime=self.lastblocktime + 1)
|
||||
for tx in txs:
|
||||
tx.rehash()
|
||||
block.vtx.append(tx)
|
||||
@ -114,7 +116,6 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
||||
assert_equal(None if accept else 'block-validation-failed', node.submitblock(block.serialize().hex()))
|
||||
if (accept):
|
||||
assert_equal(node.getbestblockhash(), block.hash)
|
||||
self.tip = block.sha256
|
||||
self.lastblockhash = block.hash
|
||||
self.lastblocktime += 1
|
||||
self.lastblockheight += 1
|
||||
|
Reference in New Issue
Block a user