44# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55"""Test connecting genesis coinbase"""
66
7+ from test_framework .messages import COIN
78from test_framework .test_framework import BitcoinTestFramework
89from test_framework .util import assert_equal , assert_raises_rpc_error
10+ from test_framework .script import OP_TRUE , CScriptOp
11+
12+ NUM_INITIAL_COINS = 50
913
1014class ConnectGenesisTest (BitcoinTestFramework ):
1115 def set_test_params (self ):
1216 self .num_nodes = 2
1317 self .setup_clean_chain = True
1418 # First node doesn't connect coinbase output to db, second does
15- self .extra_args = [["-con_connect_coinbase=0" , "-initialfreecoins=5000000000" ], ["-con_connect_coinbase=1" , "-initialfreecoins=5000000000" ]]
19+ self .extra_args = [["-con_connect_coinbase=0" , "-initialfreecoins={}" .format (NUM_INITIAL_COINS * COIN )],
20+ ["-con_connect_coinbase=1" , "-initialfreecoins={}" .format (NUM_INITIAL_COINS * COIN ), '-anyonecanspendaremine=1' ]]
1621
1722 def run_test (self ):
1823 # Same genesis block
@@ -28,11 +33,19 @@ def run_test(self):
2833 assert_equal (node0_info ["total_amount" ], 0 )
2934 assert_equal (node1_info ["txouts" ], 1 )
3035 assert_equal (node1_info ["transactions" ], 1 )
31- assert_equal (node1_info ["total_amount" ], 50 )
36+ assert_equal (node1_info ["total_amount" ], NUM_INITIAL_COINS )
3237
3338 coinbase_tx = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (0 ))["tx" ][0 ]
3439 issuance_tx = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (0 ))["tx" ][1 ]
3540
41+ # Test listunspent
42+ unspent = self .nodes [1 ].listunspent ()
43+ assert_equal (len (unspent ), 1 )
44+ assert_equal (unspent [0 ]["vout" ], 0 )
45+ assert_equal (CScriptOp (int (unspent [0 ]["scriptPubKey" ], 16 )), OP_TRUE )
46+ assert_equal (unspent [0 ]["amount" ], NUM_INITIAL_COINS )
47+ assert_equal (unspent [0 ]["confirmations" ], 1 )
48+
3649 # Test rpc getraw functionality
3750
3851 # Coinbase transaction is provably unspendable (OP_RETURN), so even AddCoin won't add it
0 commit comments