|  | 
|  | 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 | +        'memo': 'regtest2_style', | 
|  | 16 | +        'genesis': '82ba4b06cffb29f7c5426aa519ecb8e9a2b28b1df11a65c155b5054cca67583d', | 
|  | 17 | +        'args': [ | 
|  | 18 | +                '-con_genesis_style=regtest2_style', | 
|  | 19 | +        ], | 
|  | 20 | +    }, | 
|  | 21 | + | 
|  | 22 | +    { | 
|  | 23 | +        'memo': 'default_style', | 
|  | 24 | +        'genesis': 'c03f16ae9e2980de2b61fd6dc84af8ac4a37bea928af632166a6b36c5c871ddd', | 
|  | 25 | +        'args': [ | 
|  | 26 | +                '-con_genesis_style=default_style', | 
|  | 27 | +        ], | 
|  | 28 | +    }, | 
|  | 29 | +] | 
|  | 30 | + | 
|  | 31 | +class GenesisHashTest(BitcoinTestFramework): | 
|  | 32 | + | 
|  | 33 | +    def set_test_params(self): | 
|  | 34 | +        self.chain = 'signet' | 
|  | 35 | +        self.setup_clean_chain = True | 
|  | 36 | +        self.num_nodes = len(GENESIS_ARGS_MAP) | 
|  | 37 | +        self.extra_args = [item['args'] for item in GENESIS_ARGS_MAP] | 
|  | 38 | + | 
|  | 39 | +    def setup_network(self): | 
|  | 40 | +        # Don't connect the nodes as they use incompatible chains | 
|  | 41 | +        self.add_nodes(self.num_nodes, self.extra_args) | 
|  | 42 | +        self.start_nodes() | 
|  | 43 | + | 
|  | 44 | +    def run_test(self): | 
|  | 45 | +        for i in range(len(GENESIS_ARGS_MAP)): | 
|  | 46 | +            self.log.info('Check genesis style %s...' % GENESIS_ARGS_MAP[i]['memo']) | 
|  | 47 | +            assert_equal(self.nodes[i].getblockhash(0), GENESIS_ARGS_MAP[i]['genesis']) | 
|  | 48 | + | 
|  | 49 | +if __name__ == '__main__': | 
|  | 50 | +    GenesisHashTest().main() | 
0 commit comments