You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feature_help.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2018 The Bitcoin Core developers
  3. # Distributed under the MIT software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. """Verify that starting bitcoin with -h works as expected."""
  6. import subprocess
  7. from test_framework.test_framework import BitcoinTestFramework
  8. from test_framework.util import assert_equal
  9. class HelpTest(BitcoinTestFramework):
  10. def set_test_params(self):
  11. self.setup_clean_chain = True
  12. self.num_nodes = 1
  13. def setup_network(self):
  14. self.add_nodes(self.num_nodes)
  15. # Don't start the node
  16. def run_test(self):
  17. self.log.info("Start bitcoin with -h for help text")
  18. self.nodes[0].start(extra_args=['-h'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
  19. # Node should exit immediately and output help to stdout.
  20. ret_code = self.nodes[0].process.wait(timeout=1)
  21. assert_equal(ret_code, 0)
  22. output = self.nodes[0].process.stdout.read()
  23. assert b'Options' in output
  24. self.log.info("Help text received: {} (...)".format(output[0:60]))
  25. self.nodes[0].running = False
  26. self.log.info("Start bitcoin with -version for version information")
  27. self.nodes[0].start(extra_args=['-version'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
  28. # Node should exit immediately and output version to stdout.
  29. ret_code = self.nodes[0].process.wait(timeout=1)
  30. assert_equal(ret_code, 0)
  31. output = self.nodes[0].process.stdout.read()
  32. assert b'version' in output
  33. self.log.info("Version text received: {} (...)".format(output[0:60]))
  34. # Clean up TestNode state
  35. self.nodes[0].running = False
  36. self.nodes[0].process = None
  37. self.nodes[0].rpc_connected = False
  38. self.nodes[0].rpc = None
  39. if __name__ == '__main__':
  40. HelpTest().main()