@@ -32,7 +32,7 @@ class BlockchainTest(BitcoinTestFramework):
32
32
def __init__ (self ):
33
33
super ().__init__ ()
34
34
self .setup_clean_chain = False
35
- self .num_nodes = 2
35
+ self .num_nodes = 1
36
36
37
37
def run_test (self ):
38
38
self ._test_gettxoutsetinfo ()
@@ -50,9 +50,33 @@ def _test_gettxoutsetinfo(self):
50
50
assert_equal (res ['height' ], 200 )
51
51
assert_equal (res ['txouts' ], 200 )
52
52
assert_equal (res ['bytes_serialized' ], 13924 ),
53
+ assert_equal (res ['bestblock' ], node .getblockhash (200 ))
53
54
assert_equal (len (res ['bestblock' ]), 64 )
54
55
assert_equal (len (res ['hash_serialized' ]), 64 )
55
56
57
+ self .log .info ("Test that gettxoutsetinfo() works for blockchain with just the genesis block" )
58
+ b1hash = node .getblockhash (1 )
59
+ node .invalidateblock (b1hash )
60
+
61
+ res2 = node .gettxoutsetinfo ()
62
+ assert_equal (res2 ['transactions' ], 0 )
63
+ assert_equal (res2 ['total_amount' ], Decimal ('0' ))
64
+ assert_equal (res2 ['height' ], 0 )
65
+ assert_equal (res2 ['txouts' ], 0 )
66
+ assert_equal (res2 ['bestblock' ], node .getblockhash (0 ))
67
+ assert_equal (len (res2 ['hash_serialized' ]), 64 )
68
+
69
+ self .log .info ("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block" )
70
+ node .reconsiderblock (b1hash )
71
+
72
+ res3 = node .gettxoutsetinfo ()
73
+ assert_equal (res ['total_amount' ], res3 ['total_amount' ])
74
+ assert_equal (res ['transactions' ], res3 ['transactions' ])
75
+ assert_equal (res ['height' ], res3 ['height' ])
76
+ assert_equal (res ['txouts' ], res3 ['txouts' ])
77
+ assert_equal (res ['bestblock' ], res3 ['bestblock' ])
78
+ assert_equal (res ['hash_serialized' ], res3 ['hash_serialized' ])
79
+
56
80
def _test_getblockheader (self ):
57
81
node = self .nodes [0 ]
58
82
0 commit comments