mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
2972dbb951
fafe73a626 qa: Raise feature_help timeout to 5s (MarcoFalke) faabd7bc47 qa: Use files for stdout/stderr to support Windows (MarcoFalke) facb56ffaf qa: Run gen_rpcauth with sys.executable (MarcoFalke) fada8966c5 qa: Close stdout and stderr file when node stops (MarcoFalke) Pull request description: ### qa: Close stdout and stderr file when node stops Since these files are potentially deleted by the test framework for cleanup, they should be closed first. Otherwise this will lead to errors on Windows when the tests finish successfully. Side note: After the patch, it is no longer possible to reopen the file on Windows (see https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile) ### qa: Run gen_rpcauth with sys.executable Similar to `test_runner.py`, the `sys.executable` needs to be passed down into subprocesses to pass on native Windows. (Should have no effect on Linux) ### qa: Use files for stdout/stderr to support Windows It seems that using PIPE is not supported on Windows. Also, it is easier to just use the files that capture the stdout and stderr within the test node class. Tree-SHA512: ec675012b10705978606b7fcbdb287c39a8e6e3732aae2fa4041d963a3c6993c6eac6a9a3cbd5479514e7d8017fe74c12235d1ed6fed2e8af8f3c71981e91864
63 lines
2.4 KiB
Python
Executable File
63 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Verify that starting dashd with -h works as expected."""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import assert_equal
|
|
|
|
class HelpTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 1
|
|
|
|
def setup_network(self):
|
|
self.add_nodes(self.num_nodes)
|
|
# Don't start the node
|
|
|
|
def get_node_output(self, *, ret_code_expected):
|
|
ret_code = self.nodes[0].process.wait(timeout=5)
|
|
assert_equal(ret_code, ret_code_expected)
|
|
self.nodes[0].stdout.seek(0)
|
|
self.nodes[0].stderr.seek(0)
|
|
out = self.nodes[0].stdout.read()
|
|
err = self.nodes[0].stderr.read()
|
|
self.nodes[0].stdout.close()
|
|
self.nodes[0].stderr.close()
|
|
|
|
# Clean up TestNode state
|
|
self.nodes[0].running = False
|
|
self.nodes[0].process = None
|
|
self.nodes[0].rpc_connected = False
|
|
self.nodes[0].rpc = None
|
|
|
|
return out, err
|
|
|
|
def run_test(self):
|
|
self.log.info("Start dashd with -h for help text")
|
|
self.nodes[0].start(extra_args=['-h'])
|
|
# Node should exit immediately and output help to stdout.
|
|
output, _ = self.get_node_output(ret_code_expected=0)
|
|
assert b'Options' in output
|
|
self.log.info("Help text received: {} (...)".format(output[0:60]))
|
|
|
|
self.log.info("Start dashd with -version for version information")
|
|
self.nodes[0].start(extra_args=['-version'])
|
|
# Node should exit immediately and output version to stdout.
|
|
output, _ = self.get_node_output(ret_code_expected=0)
|
|
assert b'version' in output
|
|
self.log.info("Version text received: {} (...)".format(output[0:60]))
|
|
|
|
# Test that arguments not in the help results in an error
|
|
self.log.info("Start dashdd with -fakearg to make sure it does not start")
|
|
self.nodes[0].start(extra_args=['-fakearg'])
|
|
# Node should exit immediately and output an error to stderr
|
|
_, output = self.get_node_output(ret_code_expected=1)
|
|
assert b'Error parsing command line arguments' in output
|
|
self.log.info("Error message received: {} (...)".format(output[0:60]))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
HelpTest().main()
|