diff options
| author | Daniel Edgecumbe <[email protected]> | 2017-09-21 00:52:20 +0100 |
|---|---|---|
| committer | Patrick Lodder <[email protected]> | 2020-07-24 18:45:39 +0200 |
| commit | 59dcceea58529c10e3d9eecec92fd3c854350afa (patch) | |
| tree | dbad0caae9e743eb0d720f1fe6104ab7e21bde24 /qa | |
| parent | Merge pull request #1636 from patricklodder/1.14-fix-tests (diff) | |
| download | discoin-59dcceea58529c10e3d9eecec92fd3c854350afa.tar.xz discoin-59dcceea58529c10e3d9eecec92fd3c854350afa.zip | |
[backport] [rpc] getblockchaininfo: add size_on_disk, prune_target_size, automatic_pruning
Fix pruneheight help text.
Move fPruneMode block to match output ordering with help text.
Add functional tests for new fields in getblockchaininfo.
Rebase-from: bitcoin#b7dfc6c4
Diffstat (limited to 'qa')
| -rwxr-xr-x | qa/rpc-tests/blockchain.py | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py index a46e047c4..827c46d42 100755 --- a/qa/rpc-tests/blockchain.py +++ b/qa/rpc-tests/blockchain.py @@ -14,10 +14,13 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import ( assert_equal, + assert_greater_than, + assert_greater_than_or_equal, assert_raises, assert_is_hex_string, assert_is_hash_string, start_nodes, + start_node, connect_nodes_bi, ) @@ -37,7 +40,9 @@ class BlockchainTest(BitcoinTestFramework): self.num_nodes = 2 def setup_network(self, split=False): - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir) + self.nodes = [] + self.nodes.append(start_node(0, self.options.tmpdir, ["-prune=1"])) + self.nodes.append(start_node(1, self.options.tmpdir, ["-prune=2200"])) connect_nodes_bi(self.nodes, 0, 1) self.is_network_split = False self.sync_all() @@ -45,8 +50,54 @@ class BlockchainTest(BitcoinTestFramework): def run_test(self): self._test_gettxoutsetinfo() self._test_getblockheader() + self._test_getblockchaininfo() self.nodes[0].verifychain(4, 0) + # PL backported this entire test from upstream 0.16 to 1.14.3 + def _test_getblockchaininfo(self): + + keys = [ + 'bestblockhash', + 'bip9_softforks', + 'blocks', + 'chain', + 'chainwork', + 'difficulty', + 'headers', + 'initialblockdownload', + 'mediantime', + 'pruned', + 'size_on_disk', + 'softforks', + 'verificationprogress', + 'warnings', + ] + res = self.nodes[0].getblockchaininfo() + + # result should have these additional pruning keys if manual pruning is enabled + assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning'] + keys)) + + # size_on_disk should be > 0 + assert_greater_than(res['size_on_disk'], 0) + + # pruneheight should be greater or equal to 0 + assert_greater_than_or_equal(res['pruneheight'], 0) + + # check other pruning fields given that prune=1 + assert res['pruned'] + assert not res['automatic_pruning'] + + res = self.nodes[1].getblockchaininfo() + # result should have these additional pruning keys if prune=2200 + assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning', 'prune_target_size'] + keys)) + + # check related fields + assert res['pruned'] + assert_equal(res['pruneheight'], 0) + assert res['automatic_pruning'] + assert_equal(res['prune_target_size'], 2306867200) + assert_greater_than(res['size_on_disk'], 0) + def _test_gettxoutsetinfo(self): node = self.nodes[0] res = node.gettxoutsetinfo() |