mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 03:53:22 +02:00
Merge #19401: QA: Use GBT to get block versions correct
d438d609cd
QA: Use GBT to get block versions correct (Luke Dashjr)1df2cd1c8f
QA: blocktools: Accept block template to create_block (Luke Dashjr) Pull request description: The goal here is to decouple unrelated tests from the details of block versions. Currently, these tests are forcing specific versions of blocks for no real reason. ACKs for top commit: fjahr: re-ACKd438d609cd
benthecarman: ACKd438d60
Tree-SHA512: 523b1cd4dac8d65c88432e126ce7f60df96ca4b94f7ecc8e83ba4ffbade23e2afe7055fdf586ce3c195a533f2004e63fff83add4267b39473a581c9f1c6d5340
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
|
||||
from test_framework.blocktools import create_block, NORMAL_GBT_REQUEST_PARAMS, add_witness_commitment
|
||||
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, ToHex
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
@@ -275,6 +275,8 @@ class BIP68Test(BitcoinTestFramework):
|
||||
|
||||
# Advance the time on the node so that we can test timelocks
|
||||
self.nodes[0].setmocktime(cur_time+600)
|
||||
# Save block template now to use for the reorg later
|
||||
tmpl = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||
self.nodes[0].generate(1)
|
||||
assert tx2.hash not in self.nodes[0].getrawmempool()
|
||||
|
||||
@@ -318,16 +320,15 @@ class BIP68Test(BitcoinTestFramework):
|
||||
# diagram above).
|
||||
# This would cause tx2 to be added back to the mempool, which in turn causes
|
||||
# tx3 to be removed.
|
||||
tip = int(self.nodes[0].getblockhash(self.nodes[0].getblockcount()-1), 16)
|
||||
height = self.nodes[0].getblockcount()
|
||||
for i in range(2):
|
||||
block = create_block(tip, create_coinbase(height), cur_time)
|
||||
block.nVersion = 3
|
||||
block = create_block(tmpl=tmpl, ntime=cur_time)
|
||||
block.rehash()
|
||||
block.solve()
|
||||
tip = block.sha256
|
||||
height += 1
|
||||
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(ToHex(block)))
|
||||
tmpl = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||
tmpl['previousblockhash'] = '%x' % tip
|
||||
tmpl['transactions'] = []
|
||||
cur_time += 1
|
||||
|
||||
mempool = self.nodes[0].getrawmempool()
|
||||
@@ -375,9 +376,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, ToHex(tx3))
|
||||
|
||||
# make a block that violates bip68; ensure that the tip updates
|
||||
tip = int(self.nodes[0].getbestblockhash(), 16)
|
||||
block = create_block(tip, create_coinbase(self.nodes[0].getblockcount()+1))
|
||||
block.nVersion = 3
|
||||
block = create_block(tmpl=self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
|
||||
block.vtx.extend([tx1, tx2, tx3])
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
block.rehash()
|
||||
|
Reference in New Issue
Block a user