mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#20167: Add test for -blockversion
This commit is contained in:
parent
8aef3fe0d6
commit
ac0bca1de1
@ -1273,7 +1273,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
blocks = []
|
||||
spend = out[32]
|
||||
for i in range(89, LARGE_REORG_SIZE + 89):
|
||||
b = self.next_block(i, spend, version=4)
|
||||
b = self.next_block(i, spend)
|
||||
tx = CTransaction()
|
||||
script_length = MAX_BLOCK_SIZE - len(b.serialize()) - 69
|
||||
script_output = CScript([b'\x00' * script_length])
|
||||
@ -1292,18 +1292,18 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
self.move_tip(88)
|
||||
blocks2 = []
|
||||
for i in range(89, LARGE_REORG_SIZE + 89):
|
||||
blocks2.append(self.next_block("alt" + str(i), version=4))
|
||||
blocks2.append(self.next_block("alt" + str(i)))
|
||||
self.send_blocks(blocks2, False, force_send=True)
|
||||
|
||||
# extend alt chain to trigger re-org
|
||||
block = self.next_block("alt" + str(chain1_tip + 1), version=4)
|
||||
block = self.next_block("alt" + str(chain1_tip + 1))
|
||||
self.send_blocks([block], True, timeout=2440)
|
||||
|
||||
# ... and re-org back to the first chain
|
||||
self.move_tip(chain1_tip)
|
||||
block = self.next_block(chain1_tip + 1, version=4)
|
||||
block = self.next_block(chain1_tip + 1)
|
||||
self.send_blocks([block], False, force_send=True)
|
||||
block = self.next_block(chain1_tip + 2, version=4)
|
||||
block = self.next_block(chain1_tip + 2)
|
||||
self.send_blocks([block], True, timeout=2440)
|
||||
|
||||
self.log.info("Reject a block with an invalid block header version")
|
||||
@ -1311,7 +1311,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
self.send_blocks([b_v1], success=False, force_send=True, reject_reason='bad-version(0x00000001)', reconnect=True)
|
||||
|
||||
self.move_tip(chain1_tip + 2)
|
||||
b_cb34 = self.next_block('b_cb34', version=4)
|
||||
b_cb34 = self.next_block('b_cb34')
|
||||
b_cb34.vtx[0].vin[0].scriptSig = b_cb34.vtx[0].vin[0].scriptSig[:-1]
|
||||
b_cb34.vtx[0].rehash()
|
||||
b_cb34.hashMerkleRoot = b_cb34.calc_merkle_root()
|
||||
@ -1345,7 +1345,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
tx.rehash()
|
||||
return tx
|
||||
|
||||
def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), *, version=1):
|
||||
def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), *, version=4):
|
||||
if self.tip is None:
|
||||
base_block_hash = self.genesis_hash
|
||||
block_time = self.mocktime + 1
|
||||
|
@ -151,7 +151,6 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||
# and '-dip3params=2000:2000' to create pre-dip3 blocks only
|
||||
self.extra_args = [[
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
'-blockversion=4',
|
||||
'-maxtipage=600100', '-dip3params=2000:2000',
|
||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||
]]
|
||||
|
@ -44,7 +44,6 @@ class NotificationsTest(DashTestFramework):
|
||||
# -alertnotify and -blocknotify on node0, walletnotify on node1
|
||||
self.extra_args[0].append("-alertnotify=echo > {}".format(os.path.join(self.alertnotify_dir, '%s')))
|
||||
self.extra_args[0].append("-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s')))
|
||||
self.extra_args[1].append("-blockversion=211")
|
||||
self.extra_args[1].append("-rescan")
|
||||
self.extra_args[1].append("-walletnotify=echo > {}".format(os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s'))))
|
||||
|
||||
|
@ -13,6 +13,7 @@ from decimal import Decimal
|
||||
|
||||
from test_framework.blocktools import (
|
||||
create_coinbase,
|
||||
NORMAL_GBT_REQUEST_PARAMS,
|
||||
TIME_GENESIS_BLOCK,
|
||||
)
|
||||
from test_framework.messages import (
|
||||
@ -27,6 +28,8 @@ from test_framework.util import (
|
||||
assert_raises_rpc_error,
|
||||
)
|
||||
|
||||
VERSIONBITS_TOP_BITS = 0x20000000
|
||||
VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT = 28
|
||||
|
||||
def assert_template(node, block, expect, rehash=True):
|
||||
if rehash:
|
||||
@ -53,7 +56,16 @@ class MiningTest(BitcoinTestFramework):
|
||||
assert_equal(mining_info['blocks'], 200)
|
||||
assert_equal(mining_info['currentblocktx'], 0)
|
||||
assert_equal(mining_info['currentblocksize'], 1000)
|
||||
|
||||
self.log.info('test blockversion')
|
||||
self.restart_node(0, extra_args=['-mocktime={}'.format(t), '-blockversion=1337'])
|
||||
self.connect_nodes(0, 1)
|
||||
assert_equal(1337, self.nodes[0].getblocktemplate()['version'])
|
||||
self.restart_node(0, extra_args=['-mocktime={}'.format(t)])
|
||||
self.connect_nodes(0, 1)
|
||||
assert_equal(VERSIONBITS_TOP_BITS + (1 << VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT), self.nodes[0].getblocktemplate()['version'])
|
||||
self.restart_node(0)
|
||||
# TODO: replace with connect_nodes_bi
|
||||
self.connect_nodes(0, 1)
|
||||
self.connect_nodes(1, 0)
|
||||
|
||||
@ -79,7 +91,7 @@ class MiningTest(BitcoinTestFramework):
|
||||
|
||||
# Mine a block to leave initial block download
|
||||
node.generatetoaddress(1, node.get_deterministic_priv_key().address)
|
||||
tmpl = node.getblocktemplate()
|
||||
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||
self.log.info("getblocktemplate: Test capability advertised")
|
||||
assert 'proposal' in tmpl['capabilities']
|
||||
assert 'coinbasetxn' not in tmpl
|
||||
|
Loading…
Reference in New Issue
Block a user