Skip to content

Commit 57e6786

Browse files
committed
qa: Improve getchaintxstats functional test
1 parent 501b439 commit 57e6786

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/functional/rpc_blockchain.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ def _test_getblockchaininfo(self):
102102
def _test_getchaintxstats(self):
103103
self.log.info("Test getchaintxstats")
104104

105+
# Test `getchaintxstats` invalid extra parameters
106+
assert_raises_rpc_error(-1, 'getchaintxstats', self.nodes[0].getchaintxstats, 0, '', 0)
107+
108+
# Test `getchaintxstats` invalid `nblocks`
109+
assert_raises_rpc_error(-1, "JSON value is not an integer as expected", self.nodes[0].getchaintxstats, '')
110+
assert_raises_rpc_error(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, -1)
111+
assert_raises_rpc_error(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, self.nodes[0].getblockcount())
112+
113+
# Test `getchaintxstats` invalid `blockhash`
114+
assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[0].getchaintxstats, blockhash=0)
115+
assert_raises_rpc_error(-5, "Block not found", self.nodes[0].getchaintxstats, blockhash='0')
116+
blockhash = self.nodes[0].getblockhash(200)
117+
self.nodes[0].invalidateblock(blockhash)
118+
assert_raises_rpc_error(-8, "Block is not in main chain", self.nodes[0].getchaintxstats, blockhash=blockhash)
119+
self.nodes[0].reconsiderblock(blockhash)
120+
105121
chaintxstats = self.nodes[0].getchaintxstats(1)
106122
# 200 txs plus genesis tx
107123
assert_equal(chaintxstats['txcount'], 201)
@@ -133,8 +149,6 @@ def _test_getchaintxstats(self):
133149
assert('window_interval' not in chaintxstats)
134150
assert('txrate' not in chaintxstats)
135151

136-
assert_raises_rpc_error(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, 201)
137-
138152
def _test_gettxoutsetinfo(self):
139153
node = self.nodes[0]
140154
res = node.gettxoutsetinfo()

0 commit comments

Comments
 (0)