[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
  1. promag commented at 11:50 PM on September 19, 2017: member

    Adds functional test for getblockchaininfo. Also deals with the fact that pruneheight is only in the response when pruning is enabled (related to #11366).

  2. 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.

  3. fanquake added the label Tests on Sep 19, 2017
  4. in 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.

  5. 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']] in set_test_params() and then setting self.extra_args = [['-stopatheight=207']] before restarting.

  6. 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 use self.extra_args[0] for its args.

  7. jnewbery commented at 1:40 PM on September 20, 2017: member

    concept ACK. Thanks for improving coverage here!

    A few nits inline. Nothing blocking this from being merged if you don't want to take them.

  8. promag force-pushed on Sep 20, 2017
  9. promag force-pushed on Sep 20, 2017
  10. in 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 TestFramework would be methods on the TestNode class, 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.

  11. promag force-pushed on Sep 20, 2017
  12. promag force-pushed on Sep 20, 2017
  13. in 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 = .... The self.extra_args class variable is only used when instantiating the TestNode. That's important for restart_node()

  14. jnewbery commented at 2:28 PM on September 20, 2017: member

    I like the new restart_node() helper function. A couple of comments inline.

  15. [test] Add restart_node to BitcoinTestFramework fd8f45fe88
  16. [test] Add getblockchaininfo functional test f6ffb14367
  17. promag force-pushed on Sep 20, 2017
  18. in 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):
    


    promag commented at 2:39 PM on September 20, 2017:

    @jnewbery added the option to override node.extra_args. I wonder if that this new extra_arg should be saved in node.


    jnewbery commented at 3:40 PM on September 20, 2017:

    Looks good. I don't think you need to update node.extra_args

  19. esotericnonsense commented at 3:33 PM on September 20, 2017: contributor

    Noted for #11367, can update to include relevant checks (or vice versa, whichever goes in first I guess)

  20. promag commented at 3:59 PM on September 20, 2017: member

    I guess this could go in first since #11367 is a new feature. But if #11367 goes first then I'm happy to update this.

  21. jnewbery commented at 7:44 PM on September 20, 2017: member

    Tested ACK f6ffb143679aa7e89ad3c3342ceba5e5aaf71a0e

  22. 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)

  23. esotericnonsense commented at 9:46 PM on September 22, 2017: contributor

    I'll rebase on top, given that there seem to be a few niggles with #11367 this one can go in first.

  24. laanwj merged this on Sep 25, 2017
  25. laanwj closed this on Sep 25, 2017

  26. laanwj referenced this in commit 2d85899303 on Sep 25, 2017
  27. luke-jr referenced this in commit a59740a50d on Nov 11, 2017
  28. luke-jr referenced this in commit 735a63f832 on Nov 11, 2017
  29. luke-jr referenced this in commit b2194eb531 on Nov 11, 2017
  30. luke-jr referenced this in commit 2bb5a01295 on Nov 11, 2017
  31. PastaPastaPasta referenced this in commit 2d99b73ca1 on Dec 22, 2019
  32. PastaPastaPasta referenced this in commit f376b46853 on Jan 2, 2020
  33. PastaPastaPasta referenced this in commit 2329b8ebd2 on Jan 4, 2020
  34. PastaPastaPasta referenced this in commit 1f29f1c09d on Jan 12, 2020
  35. PastaPastaPasta referenced this in commit 15562d8680 on Jan 12, 2020
  36. PastaPastaPasta referenced this in commit 81461b7245 on Jan 12, 2020
  37. PastaPastaPasta referenced this in commit 4b6d804d64 on Jan 12, 2020
  38. ckti referenced this in commit 2ec6cd7dfb on Mar 28, 2021
  39. gades referenced this in commit 553a447c5c on Jun 26, 2021
  40. gades referenced this in commit bb8cb25190 on Feb 8, 2022
  41. DrahtBot locked this on Feb 15, 2022

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