|
| 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 | + |
| 8 | +from test_framework.test_framework import BitcoinTestFramework |
| 9 | +from test_framework.util import assert_equal |
| 10 | + |
| 11 | +class HelpTest(BitcoinTestFramework): |
| 12 | + def set_test_params(self): |
| 13 | + self.setup_clean_chain = True |
| 14 | + self.num_nodes = 1 |
| 15 | + |
| 16 | + def setup_network(self): |
| 17 | + self.add_nodes(self.num_nodes) |
| 18 | + # Don't start the node |
| 19 | + |
| 20 | + def run_test(self): |
| 21 | + self.log.info("Start bitcoin with -h for help text") |
| 22 | + self.nodes[0].start(extra_args=['-h'], stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
| 23 | + # Node should exit immediately and output help to stdout. |
| 24 | + ret_code = self.nodes[0].process.wait(timeout=1) |
| 25 | + assert_equal(ret_code, 0) |
| 26 | + output = self.nodes[0].process.stdout.read() |
| 27 | + assert b'Options' in output |
| 28 | + self.log.info("Help text received: {} (...)".format(output[0:60])) |
| 29 | + self.nodes[0].running = False |
| 30 | + |
| 31 | + self.log.info("Start bitcoin with -version for version information") |
| 32 | + self.nodes[0].start(extra_args=['-version'], stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
| 33 | + # Node should exit immediately and output version to stdout. |
| 34 | + ret_code = self.nodes[0].process.wait(timeout=1) |
| 35 | + assert_equal(ret_code, 0) |
| 36 | + output = self.nodes[0].process.stdout.read() |
| 37 | + assert b'version' in output |
| 38 | + self.log.info("Version text received: {} (...)".format(output[0:60])) |
| 39 | + self.nodes[0].running = False |
| 40 | + |
| 41 | +if __name__ == '__main__': |
| 42 | + HelpTest().main() |
0 commit comments