aboutsummaryrefslogtreecommitdiff
path: root/test/functional/blockchain.py
diff options
context:
space:
mode:
authorAkio Nakamura <nakamura@dgtechnologies.co.jp>2017-08-14 16:29:00 +0900
committerAkio Nakamura <nakamura@dgtechnologies.co.jp>2017-08-25 18:32:45 +0900
commit07704c1b3768d6c290046c783063644fc7b7d1da (patch)
tree28f6e29ef3d5dcfbd3d63f47896143a849ee8791 /test/functional/blockchain.py
parent33366768afe21ff85259c0712176604aab56d9ae (diff)
Add some tests for getchaintxstats
1. Add a test for no parameters. 2. Add a test for the block's height = 1. 3. Add a test for nblocks is out of range.
Diffstat (limited to 'test/functional/blockchain.py')
-rwxr-xr-xtest/functional/blockchain.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py
index 0812e1b0df..99594d9995 100755
--- a/test/functional/blockchain.py
+++ b/test/functional/blockchain.py
@@ -56,6 +56,28 @@ class BlockchainTest(BitcoinTestFramework):
# we have to round because of binary math
assert_equal(round(chaintxstats['txrate'] * 600, 10), Decimal(1))
+ b1 = self.nodes[0].getblock(self.nodes[0].getblockhash(1))
+ b200 = self.nodes[0].getblock(self.nodes[0].getblockhash(200))
+ time_diff = b200['mediantime'] - b1['mediantime']
+
+ chaintxstats = self.nodes[0].getchaintxstats()
+ assert_equal(chaintxstats['time'], b200['time'])
+ assert_equal(chaintxstats['txcount'], 201)
+ assert_equal(chaintxstats['window_block_count'], 199)
+ assert_equal(chaintxstats['window_tx_count'], 199)
+ assert_equal(chaintxstats['window_interval'], time_diff)
+ assert_equal(round(chaintxstats['txrate'] * time_diff, 10), Decimal(199))
+
+ chaintxstats = self.nodes[0].getchaintxstats(blockhash=b1['hash'])
+ assert_equal(chaintxstats['time'], b1['time'])
+ assert_equal(chaintxstats['txcount'], 2)
+ assert_equal(chaintxstats['window_block_count'], 0)
+ assert('window_tx_count' not in chaintxstats)
+ assert('window_interval' not in chaintxstats)
+ assert('txrate' not in chaintxstats)
+
+ assert_raises_jsonrpc(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, 201)
+
def _test_gettxoutsetinfo(self):
node = self.nodes[0]
res = node.gettxoutsetinfo()