diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-09-07 01:43:16 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-09-07 01:46:24 +0200 |
commit | 645a7ecc0b8d69c7a4733b1f8548730b8ffa033c (patch) | |
tree | a7a0a3a1b348daec3ac563bb14558d639f8a61f2 /src/bitcoin-cli.cpp | |
parent | 66a5b419eff57588f674ef7f409c389b71bebb22 (diff) | |
parent | 29e1dfbd9793203479b8499c55ffec2086f5ab39 (diff) |
Merge #11125: Add bitcoin-cli -stdin and -stdinrpcpass functional tests
29e1dfbd9 [test] Add bitcoin-cli -stdin and -stdinrpcpass functional tests (João Barbosa)
ce379b47b [test] Replace check_output with low level version (João Barbosa)
232e3e847 [test] Add assert_raises_process_error to assert process errors (João Barbosa)
5c18a84b9 [test] Add support for custom arguments to TestNodeCLI (João Barbosa)
e1274947d [test] Improve assert_raises_jsonrpc docstring (João Barbosa)
769684132 Fix style in -stdin and -stdinrpcpass handling (João Barbosa)
Pull request description:
This patch adds tests for `bitcoin-cli` options `-stdin` (#7550) and `-stdinrpcpass` #10997.
Tree-SHA512: fd8133f44876f2b5b41dfd3762b1988598f6b7bf13fb2385ad95876825d9c0b2b896ce4ea6eeb21012158e1f276907f155d37bb967198b609d2d3dddbfa334c1
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r-- | src/bitcoin-cli.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index fca6083ea8..3c94c99b3e 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -296,19 +296,22 @@ int CommandLineRPC(int argc, char *argv[]) } std::string rpcPass; if (gArgs.GetBoolArg("-stdinrpcpass", false)) { - if(!std::getline(std::cin,rpcPass)) + if (!std::getline(std::cin, rpcPass)) { throw std::runtime_error("-stdinrpcpass specified but failed to read from standard input"); + } gArgs.ForceSetArg("-rpcpassword", rpcPass); } std::vector<std::string> args = std::vector<std::string>(&argv[1], &argv[argc]); if (gArgs.GetBoolArg("-stdin", false)) { // Read one arg per line from stdin and append std::string line; - while (std::getline(std::cin,line)) + while (std::getline(std::cin, line)) { args.push_back(line); + } } - if (args.size() < 1) + if (args.size() < 1) { throw std::runtime_error("too few parameters (need at least command)"); + } std::string strMethod = args[0]; args.erase(args.begin()); // Remove trailing method name from arguments vector |