@@ -56,6 +56,28 @@ def _test_getchaintxstats(self):
56
56
# we have to round because of binary math
57
57
assert_equal (round (chaintxstats ['txrate' ] * 600 , 10 ), Decimal (1 ))
58
58
59
+ b1 = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (1 ))
60
+ b200 = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (200 ))
61
+ time_diff = b200 ['mediantime' ] - b1 ['mediantime' ]
62
+
63
+ chaintxstats = self .nodes [0 ].getchaintxstats ()
64
+ assert_equal (chaintxstats ['time' ], b200 ['time' ])
65
+ assert_equal (chaintxstats ['txcount' ], 201 )
66
+ assert_equal (chaintxstats ['window_block_count' ], 199 )
67
+ assert_equal (chaintxstats ['window_tx_count' ], 199 )
68
+ assert_equal (chaintxstats ['window_interval' ], time_diff )
69
+ assert_equal (round (chaintxstats ['txrate' ] * time_diff , 10 ), Decimal (199 ))
70
+
71
+ chaintxstats = self .nodes [0 ].getchaintxstats (blockhash = b1 ['hash' ])
72
+ assert_equal (chaintxstats ['time' ], b1 ['time' ])
73
+ assert_equal (chaintxstats ['txcount' ], 2 )
74
+ assert_equal (chaintxstats ['window_block_count' ], 0 )
75
+ assert ('window_tx_count' not in chaintxstats )
76
+ assert ('window_interval' not in chaintxstats )
77
+ assert ('txrate' not in chaintxstats )
78
+
79
+ assert_raises_jsonrpc (- 8 , "Invalid block count: should be between 0 and the block's height - 1" , self .nodes [0 ].getchaintxstats , 201 )
80
+
59
81
def _test_gettxoutsetinfo (self ):
60
82
node = self .nodes [0 ]
61
83
res = node .gettxoutsetinfo ()
0 commit comments