Skip to content

Commit

Permalink
Test listunspent sanity when specifying initialfreecoins
Browse files Browse the repository at this point in the history
  • Loading branch information
dongcarl committed Dec 18, 2018
1 parent 1ac14fc commit 95432aa
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/functional/feature_connect_coinbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test connecting genesis coinbase"""

from test_framework.messages import COIN
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.script import OP_TRUE, CScriptOp

NUM_INITIAL_COINS = 50

class ConnectGenesisTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True
# First node doesn't connect coinbase output to db, second does
self.extra_args = [["-con_connect_coinbase=0", "-initialfreecoins=5000000000"], ["-con_connect_coinbase=1", "-initialfreecoins=5000000000"]]
self.extra_args = [["-con_connect_coinbase=0", "-initialfreecoins={}".format(NUM_INITIAL_COINS * COIN)],
["-con_connect_coinbase=1", "-initialfreecoins={}".format(NUM_INITIAL_COINS * COIN), '-anyonecanspendaremine=1']]

def run_test(self):
# Same genesis block
Expand All @@ -28,11 +33,19 @@ def run_test(self):
assert_equal(node0_info["total_amount"], 0)
assert_equal(node1_info["txouts"], 1)
assert_equal(node1_info["transactions"], 1)
assert_equal(node1_info["total_amount"], 50)
assert_equal(node1_info["total_amount"], NUM_INITIAL_COINS)

coinbase_tx = self.nodes[0].getblock(self.nodes[0].getblockhash(0))["tx"][0]
issuance_tx = self.nodes[0].getblock(self.nodes[0].getblockhash(0))["tx"][1]

# Test listunspent
unspent = self.nodes[1].listunspent()
assert_equal(len(unspent), 1)
assert_equal(unspent[0]["vout"], 0)
assert_equal(CScriptOp(int(unspent[0]["scriptPubKey"], 16)), OP_TRUE)
assert_equal(unspent[0]["amount"], NUM_INITIAL_COINS)
assert_equal(unspent[0]["confirmations"], 1)

# Test rpc getraw functionality

# Coinbase transaction is provably unspendable (OP_RETURN), so even AddCoin won't add it
Expand Down

0 comments on commit 95432aa

Please sign in to comment.