diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-08-26 10:04:46 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-08-26 10:04:57 +0200 |
commit | 718d9f2f77270303b2f95dc275cbf416dfd4567b (patch) | |
tree | 0559eec25142184a5e0347e85f80be4c4ac8baa6 /test/functional/rpc_signrawtransaction.py | |
parent | cea38b491f6a2929097114b7b609a774f622d58a (diff) | |
parent | 42dbd9025adc200012c103d2c091cf026f1d50b1 (diff) |
Merge bitcoin/bitcoin#22660: contrib: catch bitcoin-cli RPC call errors in getcoins.py
42dbd9025adc200012c103d2c091cf026f1d50b1 contrib: return non-zero status if getcoins.py errors (Sebastian Falbesoner)
8c203cf0e1b9558b54030c284ddf7706d64cdde2 contrib: catch bitcoin-cli RPC call errors in getcoins.py (Sebastian Falbesoner)
0eca5ebaced264d041de815316eaca8cf6fef92f contrib: refactor: introduce bitcoin-cli RPC call helper in getcoins.py (Sebastian Falbesoner)
Pull request description:
This PR is based on #22565 ("[script] signet's getcoins.py improvements"), which should be reviewed first.
The signet faucet script `contrib/signet/getcoins.py` currently issues bitcoin-cli RPC calls without catching errors -- the only case tackled is if there is no `bitcoin-cli` file found. Instead of crashing with a stack-trace on a failed RPC call, the changes in this PR aim to produce a more user-friendly output (see also https://github.com/bitcoin/bitcoin/pull/22565#discussion_r683754875). Additionally, in case of any error, a non-zero status is now returned (instead of 0, indicating success), which could be useful for other scripts taking use of signet faucet script.
The most straight-forward way to test this is invoking the script without a `bitcoind` running on signet:
PR22565 branch:
```
$ ./contrib/signet/getcoins.py
error: Could not connect to the server 127.0.0.1:8332
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
Traceback (most recent call last):
File "./contrib/signet/getcoins.py", line 26, in <module>
curr_signet_hash = subprocess.check_output([args.cmd] + args.bitcoin_cli_args + ['getblockhash', '1']).strip().decode()
File "/usr/local/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['bitcoin-cli', 'getblockhash', '1']' returned non-zero exit status 1.
```
this PR branch:
```
$ ./contrib/signet/getcoins.py
error: Could not connect to the server 127.0.0.1:38332
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
-----
Error while calling "bitcoin-cli -signet getblockhash 1" (see output above).
```
ACKs for top commit:
kallewoof:
Code ACK 42dbd9025adc200012c103d2c091cf026f1d50b1
Zero-1729:
tACK 42dbd90 🧪
Tree-SHA512: 912240a4ed03c87035e370602f4095c7ffe26806421bbbd6cf86588126f2310a01a6a61606e9e2918fb2c1a0debdd0ce768c69ba2e4b8e7750fa3474a56d01a0
Diffstat (limited to 'test/functional/rpc_signrawtransaction.py')
0 files changed, 0 insertions, 0 deletions