Skip to content

Commit c7f7b90

Browse files
committed
Test: Introduce test to check genesis block hashes
1 parent cf49637 commit c7f7b90

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2018-2018 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test genesis block hash
6+
"""
7+
8+
from test_framework.test_framework import BitcoinTestFramework
9+
from test_framework.util import (
10+
assert_equal,
11+
)
12+
13+
GENESIS_ARGS_MAP = [
14+
15+
{
16+
'memo': 'regtest2_style',
17+
'genesis': '82ba4b06cffb29f7c5426aa519ecb8e9a2b28b1df11a65c155b5054cca67583d',
18+
'args': [
19+
'-con_genesis_style=regtest2_style',
20+
],
21+
},
22+
23+
{
24+
'memo': 'default_style',
25+
'genesis': 'c03f16ae9e2980de2b61fd6dc84af8ac4a37bea928af632166a6b36c5c871ddd',
26+
'args': [
27+
'-con_genesis_style=default_style',
28+
],
29+
},
30+
31+
]
32+
33+
class GenesisHashTest(BitcoinTestFramework):
34+
35+
def set_test_params(self):
36+
self.chain = 'signet'
37+
self.setup_clean_chain = True
38+
self.num_nodes = len(GENESIS_ARGS_MAP)
39+
self.extra_args = [item['args'] for item in GENESIS_ARGS_MAP]
40+
41+
def setup_network(self):
42+
# Don't connect the nodes as they use incompatible chains
43+
self.add_nodes(self.num_nodes, self.extra_args)
44+
self.start_nodes()
45+
46+
def run_test(self):
47+
for i in range(len(GENESIS_ARGS_MAP)):
48+
self.log.info('Check genesis style %s...' % GENESIS_ARGS_MAP[i]['memo'])
49+
assert_equal(self.nodes[i].getblockhash(0), GENESIS_ARGS_MAP[i]['genesis'])
50+
51+
if __name__ == '__main__':
52+
GenesisHashTest().main()

test/functional/test_runner.py

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
'rpc_scantxoutset.py',
151151
'feature_logging.py',
152152
'p2p_node_network_limited.py',
153+
'feature_genesishash.py',
153154
'feature_blocksdir.py',
154155
'feature_config_args.py',
155156
'feature_help.py',

0 commit comments

Comments
 (0)