33
33
class BlockchainTest (BitcoinTestFramework ):
34
34
def set_test_params (self ):
35
35
self .num_nodes = 1
36
- self .extra_args = [['-stopatheight=207' ]]
36
+ self .extra_args = [['-stopatheight=207' , '-prune=1' ]]
37
37
38
38
def run_test (self ):
39
+ self ._test_getblockchaininfo ()
39
40
self ._test_getchaintxstats ()
40
41
self ._test_gettxoutsetinfo ()
41
42
self ._test_getblockheader ()
@@ -44,6 +45,33 @@ def run_test(self):
44
45
self ._test_stopatheight ()
45
46
assert self .nodes [0 ].verifychain (4 , 0 )
46
47
48
+ def _test_getblockchaininfo (self ):
49
+ self .log .info ("Test getblockchaininfo" )
50
+
51
+ keys = [
52
+ 'bestblockhash' ,
53
+ 'bip9_softforks' ,
54
+ 'blocks' ,
55
+ 'chain' ,
56
+ 'chainwork' ,
57
+ 'difficulty' ,
58
+ 'headers' ,
59
+ 'mediantime' ,
60
+ 'pruned' ,
61
+ 'softforks' ,
62
+ 'verificationprogress' ,
63
+ ]
64
+ res = self .nodes [0 ].getblockchaininfo ()
65
+ # result should have pruneheight and default keys if pruning is enabled
66
+ assert_equal (sorted (res .keys ()), sorted (['pruneheight' ] + keys ))
67
+ # pruneheight should be greater or equal to 0
68
+ assert res ['pruneheight' ] >= 0
69
+
70
+ self .restart_node (0 , ['-stopatheight=207' ])
71
+ res = self .nodes [0 ].getblockchaininfo ()
72
+ # should have exact keys
73
+ assert_equal (sorted (res .keys ()), keys )
74
+
47
75
def _test_getchaintxstats (self ):
48
76
chaintxstats = self .nodes [0 ].getchaintxstats (1 )
49
77
# 200 txs plus genesis tx
0 commit comments