Skip to content

test: add functional tests for -deprecatedrpc=permissive_bool#7246

Open
knst wants to merge 2 commits intodashpay:developfrom
knst:test-permissive-bool
Open

test: add functional tests for -deprecatedrpc=permissive_bool#7246
knst wants to merge 2 commits intodashpay:developfrom
knst:test-permissive-bool

Conversation

@knst
Copy link
Copy Markdown
Collaborator

@knst knst commented Mar 24, 2026

Issue being fixed or feature implemented

Follow-up for #7099

What was done?

Added functional tests for #7099

How Has This Been Tested?

See new functional tests inside rpc_deprecated.py

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@knst knst added this to the 24 milestone Mar 24, 2026
@knst knst requested a review from kwvg March 24, 2026 07:55
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@knst knst force-pushed the test-permissive-bool branch from 079a5f2 to 4838f65 Compare March 24, 2026 07:56
@knst knst force-pushed the test-permissive-bool branch from 4838f65 to 00d18f8 Compare March 27, 2026 09:33
@knst knst marked this pull request as ready for review March 27, 2026 09:33
@knst knst requested review from PastaPastaPasta and UdjinM6 March 27, 2026 09:34
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Walkthrough

The test file was updated to validate the -deprecatedrpc=permissive_bool behavior. Two nodes are started: node 0 with default (strict) parsing and node 1 with -deprecatedrpc=permissive_bool. A new test_permissive_bool() method was added and invoked from run_test(). It funds node 0, then calls protx("list", "valid", "detailed") with various boolean and legacy boolean forms. On node 0 only JSON booleans are accepted; legacy forms fail with RPC error -8 and a specific message. On node 1 both JSON booleans and legacy forms are accepted; other invalid values still fail with -8.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Test as Test Harness
participant Node0 as Node 0 (strict)
participant Node1 as Node 1 (permissive)
Test->>Node0: fundnode / setup
Note right of Node0: Node0 started without -deprecatedrpc
Test->>Node0: protx("list","valid","detailed") with True/1/"1"/"yes"/"no"/2/"notabool"
alt input is JSON boolean
Node0-->>Test: success (accepted)
else legacy boolean forms (1/"1"/"yes"/"no")
Node0-->>Test: RPC error -8 (must use -deprecatedrpc=permissive_bool)
else invalid values (2/"notabool")
Node0-->>Test: RPC error -8 (must be boolean)
end
Test->>Node1: protx("list","valid","detailed") with True/1/"1"/"yes"/"no"/2/"notabool"
Note right of Node1: Node1 started with -deprecatedrpc=permissive_bool
alt JSON boolean or legacy boolean forms
Node1-->>Test: success (accepted)
else invalid values (2/"notabool")
Node1-->>Test: RPC error -8 (must be boolean)
end

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding functional tests for the -deprecatedrpc=permissive_bool option, which aligns directly with the changeset modifications.
Description check ✅ Passed The PR description is directly related to the changeset, explaining it's a follow-up to PR #7099 that adds functional tests for the -deprecatedrpc=permissive_bool feature in rpc_deprecated.py.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/functional/rpc_deprecated.py (1)

16-27: ⚠️ Potential issue | 🟡 Minor

Update stale log message after adding a real deprecated RPC test.

Line 27 currently logs "No tested deprecated RPC methods", but Line 16 now runs test_permissive_bool(). This makes test output misleading.

Suggested fix
-        self.log.info("No tested deprecated RPC methods")
+        self.log.info("Tested deprecated RPC parsing with -deprecatedrpc=permissive_bool")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/functional/rpc_deprecated.py` around lines 16 - 27, The log message "No
tested deprecated RPC methods" is now misleading because test_permissive_bool()
is executed; update the log in run_test (the self.log.info call) to reflect the
actual test being run (e.g., log that permissive boolean/deprecated-RPC behavior
is being tested) or remove the message entirely; locate the self.log.info
invocation near test_permissive_bool() and change its text to accurately
describe the test (referencing test_permissive_bool or the deprecated-RPC check)
so test output is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@test/functional/rpc_deprecated.py`:
- Around line 16-27: The log message "No tested deprecated RPC methods" is now
misleading because test_permissive_bool() is executed; update the log in
run_test (the self.log.info call) to reflect the actual test being run (e.g.,
log that permissive boolean/deprecated-RPC behavior is being tested) or remove
the message entirely; locate the self.log.info invocation near
test_permissive_bool() and change its text to accurately describe the test
(referencing test_permissive_bool or the deprecated-RPC check) so test output is
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 83abcfe8-d5e8-4e01-939f-2d4f1e435a5b

📥 Commits

Reviewing files that changed from the base of the PR and between d1eab6c and 00d18f8.

📒 Files selected for processing (1)
  • test/functional/rpc_deprecated.py

@UdjinM6
Copy link
Copy Markdown

UdjinM6 commented Mar 27, 2026

pls see eb8d292

Add full coverage for the permissive_bool legacy input surface:
- Test falsy values (False, 0, "0") in both strict and permissive modes
- Test string aliases ("yes", "no") in both modes
- Test invalid values (2, "notabool") are still rejected in permissive mode
- Add log.info calls for test sections
- Comment out stale "No tested deprecated RPC methods" message

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/functional/rpc_deprecated.py (1)

36-51: Consider table-driven assertions to reduce duplication and future misses.

Lines 36-51 repeat many near-identical assertions. A small loop-based structure would keep intent clearer and make it easier to extend token coverage safely.

♻️ Refactor sketch
-        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", "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")
+        strict_legacy_values = [1, "1", 0, "0", "yes", "no", "true", "false"]
+        strict_err = "detailed must be a JSON boolean. Pass -deprecatedrpc=permissive_bool to allow legacy boolean parsing."
+        for value in strict_legacy_values:
+            assert_raises_rpc_error(-8, strict_err, self.nodes[0].protx, "list", "valid", value)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/functional/rpc_deprecated.py` around lines 36 - 51, Replace the repeated
near-identical assertions with two small table-driven loops: define a list of
test_values = [True, 1, "1", False, 0, "0", "yes", "no"] (or separate
legacy_values for node0 that should raise), then for node0 iterate over the
values and call 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", val) and for node1 iterate and call
assert_equal([], self.nodes[1].protx("list", "valid", val)); this consolidates
the repeated assertions around the existing helpers assert_raises_rpc_error,
self.nodes[0].protx, self.nodes[1].protx and assert_equal into concise loops.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/functional/rpc_deprecated.py`:
- Around line 43-55: Add assertions to cover legacy string booleans "true" and
"false" accepted by ParseBoolV in permissive mode: update the protx tests that
currently assert acceptance for 1/0, "1"/"0", "yes"/"no" by adding
assert_equal([], self.nodes[1].protx("list", "valid", "true")) and
assert_equal([], self.nodes[1].protx("list", "valid", "false")) so the
permissive-path for ParseBoolV and the protx("list","valid",...) calls are fully
exercised.

---

Nitpick comments:
In `@test/functional/rpc_deprecated.py`:
- Around line 36-51: Replace the repeated near-identical assertions with two
small table-driven loops: define a list of test_values = [True, 1, "1", False,
0, "0", "yes", "no"] (or separate legacy_values for node0 that should raise),
then for node0 iterate over the values and call 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", val) and for
node1 iterate and call assert_equal([], self.nodes[1].protx("list", "valid",
val)); this consolidates the repeated assertions around the existing helpers
assert_raises_rpc_error, self.nodes[0].protx, self.nodes[1].protx and
assert_equal into concise loops.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9bcc1dc2-4f34-4203-b0d8-847ce48ace31

📥 Commits

Reviewing files that changed from the base of the PR and between 00d18f8 and 47e7cd1.

📒 Files selected for processing (1)
  • test/functional/rpc_deprecated.py

Comment on lines +43 to +55
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", "yes"))
assert_equal([], self.nodes[1].protx("list", "valid", "no"))

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")
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add missing legacy string coverage for "true"/"false" in permissive mode.

At Line 43-55, permissive-mode assertions cover 1/0, "1"/"0", "yes"/"no" but miss "true" and "false", which are explicitly accepted by ParseBoolV. This leaves part of the legacy input surface untested.

💡 Suggested patch
         assert_equal([], self.nodes[1].protx("list", "valid", "yes"))
         assert_equal([], self.nodes[1].protx("list", "valid", "no"))
+        assert_equal([], self.nodes[1].protx("list", "valid", "true"))
+        assert_equal([], self.nodes[1].protx("list", "valid", "false"))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/functional/rpc_deprecated.py` around lines 43 - 55, Add assertions to
cover legacy string booleans "true" and "false" accepted by ParseBoolV in
permissive mode: update the protx tests that currently assert acceptance for
1/0, "1"/"0", "yes"/"no" by adding assert_equal([], self.nodes[1].protx("list",
"valid", "true")) and assert_equal([], self.nodes[1].protx("list", "valid",
"false")) so the permissive-path for ParseBoolV and the
protx("list","valid",...) calls are fully exercised.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Should be added to non-permissive mode too.

diff --git a/test/functional/rpc_deprecated.py b/test/functional/rpc_deprecated.py
index e7cb4adb98..0780b85158 100755
--- a/test/functional/rpc_deprecated.py
+++ b/test/functional/rpc_deprecated.py
@@ -37,6 +37,8 @@ class DeprecatedRpcTest(BitcoinTestFramework):
         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")
 
@@ -47,6 +49,8 @@ class DeprecatedRpcTest(BitcoinTestFramework):
         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"))
 

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UdjinM6, great point! The "true" and "false" string forms should indeed also be verified as rejected on node 0 (strict mode), since they are part of the same ParseBoolV legacy surface. The combined patch covering both nodes is:

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

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

This ensures the full ParseBoolV legacy input surface — including the "true"/"false" string aliases — is exercised symmetrically across both strict and permissive modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants