Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions test/functional/rpc_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 +46 to +55
Copy link
Copy Markdown

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 to true/false/yes/no/1/0. The test covers only lowercase strings ("true", "false", "yes", "no"), so the ToLower() branch is not exercised by mixed/upper-case inputs.

source: ['claude']

🤖 Fix this with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `test/functional/rpc_deprecated.py`:
- [SUGGESTION] lines 46-55: Permissive-mode test misses case-insensitive string coverage
  Verified. In `src/rpc/util.cpp`, `ParseBoolV()` lowercases permissive string inputs before comparing them to `true/false/yes/no/1/0`. The test covers only lowercase strings (`"true"`, `"false"`, `"yes"`, `"no"`), so the `ToLower()` branch is not exercised by mixed/upper-case inputs.

Comment on lines +34 to +55
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 setup_clean_chain = True and only mines one block; it never registers any ProTx entries. In src/rpc/evo.cpp, protx list valid iterates the deterministic MN list and returns one entry per masternode, but on this setup that list is empty, so both detailed=true and detailed=false produce []. As a result, the success cases show that permissive inputs are accepted without error, but they do not distinguish whether inputs like 1, "1", "true", or "yes" were coerced to the correct boolean value.

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")

if __name__ == '__main__':
DeprecatedRpcTest().main()
Loading