Skip to content

Commit fa9b485

Browse files
author
MarcoFalke
committed
test: Add test for -blockversion
1 parent fa7fb0e commit fa9b485

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/functional/mining_basic.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from test_framework.blocktools import (
1515
create_coinbase,
16+
NORMAL_GBT_REQUEST_PARAMS,
1617
TIME_GENESIS_BLOCK,
1718
)
1819
from test_framework.messages import (
@@ -25,9 +26,11 @@
2526
from test_framework.util import (
2627
assert_equal,
2728
assert_raises_rpc_error,
28-
connect_nodes,
2929
)
3030

31+
VERSIONBITS_TOP_BITS = 0x20000000
32+
VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT = 28
33+
3134

3235
def assert_template(node, block, expect, rehash=True):
3336
if rehash:
@@ -55,8 +58,16 @@ def mine_chain(self):
5558
assert_equal(mining_info['blocks'], 200)
5659
assert_equal(mining_info['currentblocktx'], 0)
5760
assert_equal(mining_info['currentblockweight'], 4000)
61+
62+
self.log.info('test blockversion')
63+
self.restart_node(0, extra_args=['-mocktime={}'.format(t), '-blockversion=1337'])
64+
self.connect_nodes(0, 1)
65+
assert_equal(1337, self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)['version'])
66+
self.restart_node(0, extra_args=['-mocktime={}'.format(t)])
67+
self.connect_nodes(0, 1)
68+
assert_equal(VERSIONBITS_TOP_BITS + (1 << VERSIONBITS_DEPLOYMENT_TESTDUMMY_BIT), self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)['version'])
5869
self.restart_node(0)
59-
connect_nodes(self.nodes[0], 1)
70+
self.connect_nodes(0, 1)
6071

6172
def run_test(self):
6273
self.mine_chain()
@@ -80,7 +91,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
8091

8192
# Mine a block to leave initial block download
8293
node.generatetoaddress(1, node.get_deterministic_priv_key().address)
83-
tmpl = node.getblocktemplate({'rules': ['segwit']})
94+
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
8495
self.log.info("getblocktemplate: Test capability advertised")
8596
assert 'proposal' in tmpl['capabilities']
8697
assert 'coinbasetxn' not in tmpl

0 commit comments

Comments
 (0)