Currently a few return values are undocumented. This is causing confusion at the least. See for example #18476
Fix this by treating it as an internal bug to return undocumented return values.
Currently a few return values are undocumented. This is causing confusion at the least. See for example #18476
Fix this by treating it as an internal bug to return undocumented return values.
Concept ACK but it would be much better if checks like this could be done at compile time instead of run time. This seems to me like a kind of a python-esque solution instead of a static language one.
UniValue::getType() is not a compile-time constant, so I don't think this works at compile time (without replacing UniValue with something else)
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
concept ACK, very nice! having a programatic check that the docs are in sync with the actual output seems like a win for maintaining up-to-date docs & reducing review burden
552 | - }, 553 | - RPCResult{ 554 | - RPCResult::Type::OBJ, "", "", 555 | + }, 556 | + { 557 | + RPCResult{"When mode=='proposal'", RPCResult::Type::STR, "", ""},
Nit: using single quotes isn't valid JSON or C++. Maybe use double quotes?
The existing docs use single quotes:
So I used that. Also, a lot of RPC clients are implemented in python, which also allows single quotes.
2182 | - }, 2183 | - RPCResult{ 2184 | - RPCResult::Type::OBJ, "", "", 2185 | + }, 2186 | + { 2187 | + RPCResult{"When action=='abort'", RPCResult::Type::BOOL, "", ""},
Same here: single quotes isn't valid JSON.
748 | + case Type::STR: 749 | + case Type::STR_HEX: { 750 | + return UniValue::VSTR == result.getType(); 751 | + } 752 | + case Type::NUM: 753 | + case Type::NUM_AMOUNT:
Suggestion for a follow-up: for NUM_AMOUNT, you can do a stronger test (parse with AmountFromValue, convert back to JSON using ValueFromAmount, and the string representation must match exactly).
utACK faca73c07461f3344c7f88ea63727d9ac1c70b2a
148 | @@ -149,6 +149,7 @@ static RPCHelpMan help() 149 | } 150 | if (strCommand == "dump_all_command_conversions") { 151 | // Used for testing only, undocumented 152 | + const_cast<JSONRPCRequest&>(jsonRequest).mode = JSONRPCRequest::GET_ARGS;
This is currently safe to do, because JSONRPCRequest isn't const where it is (copy-)constructed. I don't like the const_cast myself, but the only alternative I came up with was to change every rpc method with the new signature. Any other ideas? Maybe @ryanofsky
re: #20459 (review)
This is currently safe to do, because JSONRPCRequest isn't const where it is (copy-)constructed. I don't like the const_cast myself, but the only alternative I came up with was to change every rpc method with the new signature. Any other ideas? Maybe @ryanofsky
I think it would be better add ANY to list of acceptable result types: 4d692e282d404ce3d25a51261a1c6958ebd8b196 (tag). Advantages of this approach:
GET_ARGS can still mean "get arguments" instead of "get arguments and ignore result type"Thanks, done
Code review ACK fabf0515c6c58096aafb6685daf1830a34bf5c75. Suggested a tweak to get rid of const_cast, but current implementation also looks good, so feel free to ignore suggestion.
Code review ACK fa8192f42e1d24444f1d0433c96dbce1adf76967. Only changes: rebase, no const_cast suggestion, and tostring cleanups needed after suggestion