diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-10-28 11:56:43 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-10-28 12:00:36 +0100 |
commit | 9ae468a6d5250c6d55b4879834179ceec1ecc180 (patch) | |
tree | fab39001507bbcc8a22943dbb54476e4dc8c3702 /test | |
parent | be50469217bd775c4305938634c32e5932f47841 (diff) | |
parent | faeb6665362e35f573ad715ade0ef2db62d71839 (diff) |
Merge #17192: util: Add CHECK_NONFATAL and use it in src/rpc
faeb6665362e35f573ad715ade0ef2db62d71839 util: Add CHECK_NONFATAL and use it in src/rpc (MarcoFalke)
Pull request description:
Fixes #17181
Currently, we use `assert` in RPC code to document logic and code assumptions. However, it seems a bit extreme to abort all of Bitcoin Core on an assert failure in one of the RPC threads. I suggest to replace all `assert`s with a macro `CHECK_NONFATAL(condition)` that throws a runtime error when the condition evaluates to `false`. That runtime error will then be returned to the rpc caller and will include instructions to report the error to our issue tracker.
ACKs for top commit:
practicalswift:
ACK faeb6665362e35f573ad715ade0ef2db62d71839
laanwj:
ACK faeb6665362e35f573ad715ade0ef2db62d71839
ryanofsky:
Code review ACK faeb6665362e35f573ad715ade0ef2db62d71839
Tree-SHA512: 9b748715a5e0767ac11f1324a95a3a6ec672a0e0658013492219223bda83ce4b1b447fd8183bbb235f7df5ef7dddda7666ad569544b4d61cc65f232ca7a800ec
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/rpc_misc.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py index 8a3f8c6f06..3da9f05ca5 100755 --- a/test/functional/rpc_misc.py +++ b/test/functional/rpc_misc.py @@ -23,6 +23,13 @@ class RpcMiscTest(BitcoinTestFramework): def run_test(self): node = self.nodes[0] + self.log.info("test CHECK_NONFATAL") + assert_raises_rpc_error( + -1, + "Internal bug detected: 'request.params.size() != 100'", + lambda: node.echo(*[0] * 100), + ) + self.log.info("test getmemoryinfo") memory = node.getmemoryinfo()['locked'] assert_greater_than(memory['used'], 0) |