Adds functional test for getblockchaininfo. Also deals with the fact that pruneheight is only in the response when pruning is enabled (related to #11366).
[test] Add getblockchaininfo functional test #11370
pull promag wants to merge 2 commits into bitcoin:master from promag:2017-09-add-getblockchaininfo-functional-test changing 2 files +34 −1-
promag commented at 11:50 PM on September 19, 2017: member
-
in test/functional/blockchain.py:65 in 30caa12890 outdated
60 | + 'verificationprogress', 61 | + ] 62 | + res = self.nodes[0].getblockchaininfo() 63 | + # should have exact fields 64 | + assert_equal(sorted(res.keys()), keys) 65 | +
promag commented at 11:51 PM on September 19, 2017:Should assert values or types of each field?
jnewbery commented at 1:35 PM on September 20, 2017:value: only if you're testing a meaningful value type: I don't think we do this for other RPC methods, so I wouldn't bother
Thinking about this some more, perhaps we can add some utility method
check_rpc_return_object(dict)which tests the presence and type of each field in the return object? Obviously not for this PR.fanquake added the label Tests on Sep 19, 2017in test/functional/blockchain.py:48 in 30caa12890 outdated
44 | @@ -44,6 +45,38 @@ def run_test(self): 45 | self._test_stopatheight() 46 | assert self.nodes[0].verifychain(4, 0) 47 | 48 | + def _test_getblockchaininfo(self):
jnewbery commented at 1:32 PM on September 20, 2017:suggestion: perhaps add `self.log.info("test getblockchaininfo")
promag commented at 2:02 PM on September 20, 2017:Done.
in test/functional/blockchain.py:67 in 30caa12890 outdated
62 | + res = self.nodes[0].getblockchaininfo() 63 | + # should have exact fields 64 | + assert_equal(sorted(res.keys()), keys) 65 | + 66 | + # restart node with pruning enabled 67 | + self.stop_node(0)
jnewbery commented at 1:37 PM on September 20, 2017:You can speed this test up by starting with pruning the first time, and then restart without pruning (saves one stop-start which is a slow operation). Do that by setting
self.extra_args = [['-stopatheight=207', '-prune=1']]inset_test_params()and then settingself.extra_args = [['-stopatheight=207']]before restarting.in test/functional/blockchain.py:78 in 30caa12890 outdated
73 | + # should be greater or equal to 0 74 | + assert res['pruneheight'] >= 0 75 | + 76 | + # restore node 77 | + self.stop_node(0) 78 | + self.start_node(0, self.extra_args[0])
jnewbery commented at 1:39 PM on September 20, 2017:I think you can just use
self.start_node(0). The default will useself.extra_args[0]for its args.jnewbery commented at 1:40 PM on September 20, 2017: memberconcept ACK. Thanks for improving coverage here!
A few nits inline. Nothing blocking this from being merged if you don't want to take them.
promag force-pushed on Sep 20, 2017promag force-pushed on Sep 20, 2017in test/functional/test_framework/test_framework.py:276 in 2a1a0226ee outdated
272 | @@ -273,6 +273,11 @@ def stop_nodes(self): 273 | # Wait for nodes to stop 274 | node.wait_until_stopped() 275 | 276 | + def restart_node(self, i):
promag commented at 2:03 PM on September 20, 2017:Convenient method to stop and start a node with the same arguments as before. If this gets ACK's I can push a commit to use where appropriate or submit this in a separate PR.
jnewbery commented at 2:28 PM on September 20, 2017:Great! Ideally the stop and start methods in
TestFrameworkwould be methods on theTestNodeclass, and so would this, but we can clean that up later.You can change this to:
def restart_node(self, i): """Stop and start a test node""" self.stop_node(i) self.start_node(i)As long as you also take my change to blockchain.py above.
promag force-pushed on Sep 20, 2017promag force-pushed on Sep 20, 2017in test/functional/blockchain.py:71 in 3eb13b62f4 outdated
66 | + assert_equal(sorted(res.keys()), sorted(['pruneheight'] + keys)) 67 | + # pruneheight should be greater or equal to 0 68 | + assert res['pruneheight'] >= 0 69 | + 70 | + # restart node 71 | + self.extra_args[0] = ['-stopatheight=207']
jnewbery commented at 2:26 PM on September 20, 2017:Sorry, I misled you here. You should use
self.nodes[0].extra_args = .... Theself.extra_argsclass variable is only used when instantiating the TestNode. That's important forrestart_node()jnewbery commented at 2:28 PM on September 20, 2017: memberI like the new
restart_node()helper function. A couple of comments inline.[test] Add restart_node to BitcoinTestFramework fd8f45fe88[test] Add getblockchaininfo functional test f6ffb14367promag force-pushed on Sep 20, 2017in test/functional/test_framework/test_framework.py:276 in f6ffb14367
272 | @@ -273,6 +273,11 @@ def stop_nodes(self): 273 | # Wait for nodes to stop 274 | node.wait_until_stopped() 275 | 276 | + def restart_node(self, i, extra_args=None):
jnewbery commented at 3:40 PM on September 20, 2017:Looks good. I don't think you need to update
node.extra_argsesotericnonsense commented at 3:33 PM on September 20, 2017: contributorNoted for #11367, can update to include relevant checks (or vice versa, whichever goes in first I guess)
jnewbery commented at 7:44 PM on September 20, 2017: memberTested ACK f6ffb143679aa7e89ad3c3342ceba5e5aaf71a0e
jnewbery commented at 8:22 PM on September 22, 2017: member@promag @esotericnonsense - I think it's a good idea if you decide between yourselves which should go in first and then rebase the other on top of it (otherwise there's a risk they both get merged independently and no tests are added for #11367)
esotericnonsense commented at 9:46 PM on September 22, 2017: contributorI'll rebase on top, given that there seem to be a few niggles with #11367 this one can go in first.
laanwj merged this on Sep 25, 2017laanwj closed this on Sep 25, 2017laanwj referenced this in commit 2d85899303 on Sep 25, 2017luke-jr referenced this in commit a59740a50d on Nov 11, 2017luke-jr referenced this in commit 735a63f832 on Nov 11, 2017luke-jr referenced this in commit b2194eb531 on Nov 11, 2017luke-jr referenced this in commit 2bb5a01295 on Nov 11, 2017PastaPastaPasta referenced this in commit 2d99b73ca1 on Dec 22, 2019PastaPastaPasta referenced this in commit f376b46853 on Jan 2, 2020PastaPastaPasta referenced this in commit 2329b8ebd2 on Jan 4, 2020PastaPastaPasta referenced this in commit 1f29f1c09d on Jan 12, 2020PastaPastaPasta referenced this in commit 15562d8680 on Jan 12, 2020PastaPastaPasta referenced this in commit 81461b7245 on Jan 12, 2020PastaPastaPasta referenced this in commit 4b6d804d64 on Jan 12, 2020ckti referenced this in commit 2ec6cd7dfb on Mar 28, 2021gades referenced this in commit 553a447c5c on Jun 26, 2021gades referenced this in commit bb8cb25190 on Feb 8, 2022DrahtBot locked this on Feb 15, 2022ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me