Skip to content

Commit d97920c

Browse files
committed
add functional test for coinbase connection to db
1 parent e532664 commit d97920c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2014-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 connecting genesis coinbase"""
6+
7+
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.util import assert_equal, assert_raises_rpc_error
9+
10+
class ConnectGenesisTest(BitcoinTestFramework):
11+
def set_test_params(self):
12+
self.num_nodes = 2
13+
self.setup_clean_chain = True
14+
# First node doesn't connect coinbase output to db, second does
15+
self.extra_args = [["-con_connect_coinbase=0"], ["-con_connect_coinbase=1"]]
16+
17+
def run_test(self):
18+
# Same genesis block
19+
assert_equal(self.nodes[0].getblockhash(0), self.nodes[1].getblockhash(0))
20+
21+
# Different UTXO set
22+
node0_info = self.nodes[0].gettxoutsetinfo()
23+
node1_info = self.nodes[1].gettxoutsetinfo()
24+
print(node0_info)
25+
print(node1_info)
26+
assert_equal(node0_info["txouts"], 0)
27+
assert_equal(node0_info["transactions"], 0)
28+
assert_equal(node0_info["total_amount"], 0)
29+
assert_equal(node1_info["txouts"], 1)
30+
assert_equal(node1_info["transactions"], 1)
31+
assert_equal(node1_info["total_amount"], 50)
32+
33+
coinbase_tx = self.nodes[0].getblock(self.nodes[0].getblockhash(0))["tx"][0]
34+
35+
# Test rpc getraw functionality
36+
assert_raises_rpc_error(-5, "The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved", self.nodes[0].getrawtransaction, coinbase_tx)
37+
self.nodes[1].getrawtransaction(coinbase_tx)
38+
39+
if __name__ == '__main__':
40+
ConnectGenesisTest().main()

test/functional/test_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@
154154
'feature_config_args.py',
155155
'feature_help.py',
156156
'feature_mandatory_coinbase.py',
157-
'feature_block_subsidy.py'
157+
'feature_block_subsidy.py',
158+
'feature_connect_coinbase.py',
158159
# Don't append tests at the end to avoid merge conflicts
159160
# Put them in a random line within the section that fits their approximate run-time
160161
]

0 commit comments

Comments
 (0)