-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test: add functional tests for -deprecatedrpc=permissive_bool #7246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,13 @@ | |
| # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
| """Test deprecation of RPC calls.""" | ||
| from test_framework.test_framework import BitcoinTestFramework | ||
| # from test_framework.util import assert_raises_rpc_error | ||
| from test_framework.util import assert_raises_rpc_error, assert_equal | ||
|
|
||
| class DeprecatedRpcTest(BitcoinTestFramework): | ||
| def set_test_params(self): | ||
| self.num_nodes = 2 | ||
| self.setup_clean_chain = True | ||
| self.extra_args = [[], []] | ||
| self.extra_args = [[], ["-deprecatedrpc=permissive_bool"]] | ||
|
|
||
| def run_test(self): | ||
| # This test should be used to verify correct behaviour of deprecated | ||
|
|
@@ -23,7 +23,40 @@ def run_test(self): | |
| # self.log.info("Test generate RPC") | ||
| # assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].rpc.generate, 1) | ||
| # self.generate(self.nodes[1], 1) | ||
| self.log.info("No tested deprecated RPC methods") | ||
| # self.log.info("No tested deprecated RPC methods") | ||
| self.test_permissive_bool() | ||
|
|
||
| def test_permissive_bool(self): | ||
| self.log.info("Test -deprecatedrpc=permissive_bool") | ||
| self.generate(self.nodes[0], 1) | ||
|
|
||
| self.log.info("Node 0 (strict): JSON boolean accepted, legacy types rejected") | ||
| assert_equal([], self.nodes[0].protx("list", "valid", True)) | ||
| assert_equal([], self.nodes[0].protx("list", "valid", False)) | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", 1) | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "1") | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", 0) | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "0") | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "true") | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "false") | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "yes") | ||
| assert_raises_rpc_error(-8, 'detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing.', self.nodes[0].protx, "list", "valid", "no") | ||
|
|
||
| self.log.info("Node 1 (permissive): JSON boolean and legacy types accepted") | ||
| assert_equal([], self.nodes[1].protx("list", "valid", True)) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", 1)) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "1")) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", False)) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", 0)) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "0")) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "true")) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "false")) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "yes")) | ||
| assert_equal([], self.nodes[1].protx("list", "valid", "no")) | ||
|
Comment on lines
+34
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Medium: Accepted-value checks do not verify boolean coercion Verified. This test uses source: ['codex'] |
||
|
|
||
| self.log.info("Node 1 (permissive): invalid values still rejected") | ||
| assert_raises_rpc_error(-8, "detailed must be true, false, yes, no, 1 or 0 (not '2')", self.nodes[1].protx, "list", "valid", 2) | ||
| assert_raises_rpc_error(-8, "detailed must be true, false, yes, no, 1 or 0 (not 'notabool')", self.nodes[1].protx, "list", "valid", "notabool") | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if __name__ == '__main__': | ||
| DeprecatedRpcTest().main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Permissive-mode test misses case-insensitive string coverage
Verified. In
src/rpc/util.cpp,ParseBoolV()lowercases permissive string inputs before comparing them totrue/false/yes/no/1/0. The test covers only lowercase strings ("true","false","yes","no"), so theToLower()branch is not exercised by mixed/upper-case inputs.source: ['claude']
🤖 Fix this with AI agents