aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2017-09-20 00:45:39 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2017-09-20 15:38:09 +0100
commitf6ffb143679aa7e89ad3c3342ceba5e5aaf71a0e (patch)
tree6ff33811c8f8e4e0d6143475a6407fad8f0fbc57 /test
parentfd8f45fe88c7f34785ee0724b875cf14e8a29e07 (diff)
downloadbitcoin-f6ffb143679aa7e89ad3c3342ceba5e5aaf71a0e.tar.xz
[test] Add getblockchaininfo functional test
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/blockchain.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py
index 50be9262e4..63c56d0e9b 100755
--- a/test/functional/blockchain.py
+++ b/test/functional/blockchain.py
@@ -33,9 +33,10 @@ from test_framework.util import (
class BlockchainTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
- self.extra_args = [['-stopatheight=207']]
+ self.extra_args = [['-stopatheight=207', '-prune=1']]
def run_test(self):
+ self._test_getblockchaininfo()
self._test_getchaintxstats()
self._test_gettxoutsetinfo()
self._test_getblockheader()
@@ -44,6 +45,33 @@ class BlockchainTest(BitcoinTestFramework):
self._test_stopatheight()
assert self.nodes[0].verifychain(4, 0)
+ def _test_getblockchaininfo(self):
+ self.log.info("Test getblockchaininfo")
+
+ keys = [
+ 'bestblockhash',
+ 'bip9_softforks',
+ 'blocks',
+ 'chain',
+ 'chainwork',
+ 'difficulty',
+ 'headers',
+ 'mediantime',
+ 'pruned',
+ 'softforks',
+ 'verificationprogress',
+ ]
+ res = self.nodes[0].getblockchaininfo()
+ # result should have pruneheight and default keys if pruning is enabled
+ assert_equal(sorted(res.keys()), sorted(['pruneheight'] + keys))
+ # pruneheight should be greater or equal to 0
+ assert res['pruneheight'] >= 0
+
+ self.restart_node(0, ['-stopatheight=207'])
+ res = self.nodes[0].getblockchaininfo()
+ # should have exact keys
+ assert_equal(sorted(res.keys()), keys)
+
def _test_getchaintxstats(self):
chaintxstats = self.nodes[0].getchaintxstats(1)
# 200 txs plus genesis tx