cli: Reject arguments to -getinfo #11710

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2017_11_getinfo_args changing 2 files +7 −1
  1. laanwj commented at 1:21 PM on November 17, 2017: member

    Currently it's possible to accidentally type e.g.

    bitcoin-cli -getinfo getbalance

    and get an answer which can be confusing; the trailing arguments are just ignored.

    To avoid this, throw an error if the user provides arguments to -getinfo.

  2. laanwj added the label RPC/REST/ZMQ on Nov 17, 2017
  3. fanquake commented at 2:01 PM on November 17, 2017: member

    Travis failure:

    bitcoin_cli.py failed, Duration: 1 s
    stdout:
    2017-11-17 13:47:24.232000 TestFramework (INFO): Initializing test directory /tmp/bitcoin_test_runner_20171117_134443/bitcoin_cli_303
    2017-11-17 13:47:24.492000 TestFramework (INFO): Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`
    2017-11-17 13:47:24.503000 TestFramework (INFO): Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`
    2017-11-17 13:47:24.509000 TestFramework (INFO): Test -stdinrpcpass option
    2017-11-17 13:47:24.768000 TestFramework (INFO): Test -stdin and -stdinrpcpass
    2017-11-17 13:47:25.030000 TestFramework (INFO): Compare responses from `bitcoin-cli -getinfo` and the RPCs data is retrieved from.
    2017-11-17 13:47:25.041000 TestFramework (ERROR): Unexpected exception caught during testing
    Traceback (most recent call last):
      File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 120, in main
        self.run_test()
      File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/test/functional/bitcoin_cli.py", line 39, in run_test
        cli_get_info = self.nodes[0].cli('-getinfo').help()
      File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/test_node.py", line 211, in dispatcher
        return self.send_cli(command, *args, **kwargs)
      File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/test_node.py", line 229, in send_cli
        raise subprocess.CalledProcessError(returncode, self.binary, output=cli_stderr)
    subprocess.CalledProcessError: Command '/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-pc-linux-gnu/src/bitcoin-cli' returned non-zero exit status 1
    2017-11-17 13:47:25.042000 TestFramework (INFO): Stopping nodes
    
  4. laanwj commented at 2:07 PM on November 17, 2017: member

    Strange! Seems a legit error. Will look at it.

    Ah, yes, the test seems to test something that should be failing:

        cli_get_info = self.nodes[0].cli('-getinfo').help()
    

    Will execute

        bitcoin-cli -getinfo help
    

    Which makes no sense :) Will update the test.

  5. cli: Reject arguments to -getinfo
    Currently it's possible to accidentally type e.g.
    
        bitcoin-cli -getinfo getbalance
    
    and get an answer which can be confusing; the trialing arguments are
    just ignored.
    
    To avoid this, throw an error if the user provides arguments to
    `-getinfo`.
    dcfef277b4
  6. laanwj force-pushed on Nov 17, 2017
  7. laanwj commented at 2:14 PM on November 17, 2017: member

    Updated the test, now it tests both cases correctly, travis issue should be solved.

  8. in test/functional/bitcoin_cli.py:39 in dcfef277b4
      34 | @@ -35,8 +35,11 @@ def run_test(self):
      35 |          assert_equal(["foo", "bar"], self.nodes[0].cli('-rpcuser=%s' % user, '-stdin', '-stdinrpcpass', input=password + "\nfoo\nbar").echo())
      36 |          assert_raises_process_error(1, "incorrect rpcuser or rpcpassword", self.nodes[0].cli('-rpcuser=%s' % user, '-stdin', '-stdinrpcpass', input="foo").echo)
      37 |  
      38 | +        self.log.info("Make sure that -getinfo with arguments fails")
      39 | +        assert_raises_process_error(1, "-getinfo takes no arguments", self.nodes[0].cli('-getinfo').help)
    


    promag commented at 2:22 PM on November 17, 2017:

    👍

  9. promag commented at 2:26 PM on November 17, 2017: member

    utACK dcfef27.

  10. MarcoFalke commented at 3:06 PM on November 17, 2017: member

    Tested ACK dcfef277b4920552f438c110390a5de93892a8de

  11. jonasschnelli commented at 6:44 PM on November 17, 2017: contributor

    utACK dcfef277b4920552f438c110390a5de93892a8de

  12. laanwj merged this on Nov 18, 2017
  13. laanwj closed this on Nov 18, 2017

  14. laanwj referenced this in commit 938863965f on Nov 18, 2017
  15. markblundeberg referenced this in commit 9dae9ed797 on Jun 7, 2019
  16. jtoomim referenced this in commit 3e92f5e479 on Jun 29, 2019
  17. PastaPastaPasta referenced this in commit 5a43b0d659 on Feb 13, 2020
  18. PastaPastaPasta referenced this in commit 09a7b6244b on Feb 27, 2020
  19. PastaPastaPasta referenced this in commit 150c8384a3 on Mar 14, 2020
  20. PastaPastaPasta referenced this in commit 0c97cd5cee on Mar 14, 2020
  21. ckti referenced this in commit 4400f2bd78 on Mar 28, 2021
  22. DrahtBot locked this on Sep 8, 2021

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