4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test connecting genesis coinbase"""
6
6
7
+ from test_framework .messages import COIN
7
8
from test_framework .test_framework import BitcoinTestFramework
8
9
from 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
9
13
10
14
class ConnectGenesisTest (BitcoinTestFramework ):
11
15
def set_test_params (self ):
12
16
self .num_nodes = 2
13
17
self .setup_clean_chain = True
14
18
# 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' ]]
16
21
17
22
def run_test (self ):
18
23
# Same genesis block
@@ -28,11 +33,19 @@ def run_test(self):
28
33
assert_equal (node0_info ["total_amount" ], 0 )
29
34
assert_equal (node1_info ["txouts" ], 1 )
30
35
assert_equal (node1_info ["transactions" ], 1 )
31
- assert_equal (node1_info ["total_amount" ], 50 )
36
+ assert_equal (node1_info ["total_amount" ], NUM_INITIAL_COINS )
32
37
33
38
coinbase_tx = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (0 ))["tx" ][0 ]
34
39
issuance_tx = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (0 ))["tx" ][1 ]
35
40
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
+
36
49
# Test rpc getraw functionality
37
50
38
51
# Coinbase transaction is provably unspendable (OP_RETURN), so even AddCoin won't add it
0 commit comments