Improve error messages for getblock invalid datatype.
fixes: #21717
Improve error messages for getblock invalid datatype.
fixes: #21717
937 | @@ -938,8 +938,10 @@ static RPCHelpMan getblock()
938 | if (!request.params[1].isNull()) {
939 | if(request.params[1].isNum())
might be easier to swap the if branches and make this branch bool?
Yup you're right. Updated the PR according to your comments.
935 | @@ -936,10 +936,10 @@ static RPCHelpMan getblock() 936 | 937 | int verbosity = 1; 938 | if (!request.params[1].isNull()) { 939 | - if(request.params[1].isNum()) 940 | - verbosity = request.params[1].get_int(); 941 | - else 942 | + if(request.params[1].isBool())
if (request.params[1].isBool()) {
please use the new style per the dev notes
Added tests and updated the code to the new style
Looks good. A test would be nice, if possible.
410 | @@ -410,6 +411,13 @@ def _test_getblock(self): 411 | self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data") 412 | datadir = get_datadir_path(self.options.tmpdir, 0) 413 | 414 | + try: 415 | + self.log.info("Test that getblock with invlaid verbosity type returns proper error message") 416 | + node.getblock(blockhash, "2")
You can use the assert_raises_rpc_error helper
Okie updated to use assert_raises_rpc_error instead.
review ACK 89cbab16139d91c4bcf2a7308b8b21afb0efe00e
409 | @@ -410,6 +410,9 @@ def _test_getblock(self): 410 | self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data") 411 | datadir = get_datadir_path(self.options.tmpdir, 0) 412 | 413 | + self.log.info("Test that getblock with invlaid verbosity type returns proper error message")
self.log.info("Test that getblock with invalid verbosity type returns proper error message")
My apologies for that. Have updated the PR to fix the typos. Thanks!
Thanks for fixing, welcome as a new contributor! 🎉
Almost-ACK, there are two typos: one in the commit subject (s/getbloack/getblock/), and one in the test log message (s/invlaid/invalid/).
ACK a41149426168b8ea96099f10576022c6a09033d1
Code review ACK a41149426168b8ea96099f10576022c6a09033d1.