Skip to content

test: cover use_cj success path in rpc_coinjoin.py - #7637

Merged
PastaPastaPasta merged 2 commits into
dashpay:developfrom
PastaPastaPasta:test-use-cj-success
Aug 23, 2026
Merged

test: cover use_cj success path in rpc_coinjoin.py#7637
PastaPastaPasta merged 2 commits into
dashpay:developfrom
PastaPastaPasta:test-use-cj-success

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Follow-up to #7261. The use_cj tests added there only exercise failure paths: the test wallet never holds a fully mixed coin, so nothing verifies that a successful use_cj spend actually selects mixed inputs, suppresses change, or records the DS="1" CoinJoin marker that FinishTransaction() now attaches via CommitTransaction(). A regression in any of those would pass the suite unnoticed.

What was done?

Added a success-path subtest to test/functional/rpc_coinjoin.py. It builds two fully mixed coins by simulating mixing: same-denomination, fee-free self-spends advance a denominated output by one round each, and they are mined directly via generateblock since zero-fee transactions are not relayed. Chaining COINJOIN_ROUNDS_MIN + COINJOIN_RANDOM_ROUNDS rounds makes IsFullyMixed() deterministic regardless of the wallet's salt (the salt-based coin flip only applies strictly below that threshold).

It then asserts:

  • both coins report full coinjoin_rounds in listunspent and count towards the getbalances anonymized balance;
  • send accepts a fully mixed preset input (the positive counterpart of the rejection tests from feat: add use_cj feature to RPCs send, sendall and fundrawtransaction #7261), spends exactly that input, creates no change output (the remainder is paid as fee, as fully mixed coins are spent in whole denominations) and records DS="1";
  • sendall with automatic selection sweeps exactly the remaining fully mixed coin and records DS="1".

setcoinjoinrounds is a node-global setting; the subtest pins it to COINJOIN_ROUNDS_MIN and restores the default at the end so later subtests are unaffected.

How Has This Been Tested?

test/functional/test_runner.py rpc_coinjoin.py passes locally (macOS arm64, --enable-debug build, both descriptor and legacy wallet paths of the runner's default). test/lint/lint-python.py clean.

Breaking Changes

None, test-only change.

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)

The use_cj tests added in dash#7261 only exercise failure paths: the test wallet never holds a fully mixed coin, so nothing verifies that a successful use_cj spend actually selects mixed inputs, suppresses change, or records the DS="1" CoinJoin marker that FinishTransaction now attaches via CommitTransaction. A regression in any of those would pass the suite unnoticed.

Build two fully mixed coins by simulating mixing rounds with same-denomination fee-free self-spends (mined directly, since zero-fee transactions are not relayed) up to COINJOIN_ROUNDS_MIN + COINJOIN_RANDOM_ROUNDS rounds, which makes IsFullyMixed() deterministic regardless of the wallet salt. Then assert listunspent rounds and the anonymized balance, a send with a fully mixed preset input (single input, no change, DS="1") and a sendall sweep of the remaining mixed coin (DS="1").
@thepastaclaw

thepastaclaw commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — next in queue (commit 2821f84)
Queue position: 1/1
ETA: start ~15:20 UTC · complete ~15:41 UTC (median 21m across 30 recent reviews; 2 slots)
Queued 1m ago · Last checked: 2026-08-23 15:20 UTC

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1cb19e27-6dfc-411f-b5af-aa7a66b62171

📥 Commits

Reviewing files that changed from the base of the PR and between 1cb2b49 and 2821f84.

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

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The functional test adds precise amount handling and a three-round CoinJoin constant. It simulates mined self-spends for equal-denomination outputs. The test verifies mixed balances and checks that send and sendall create CoinJoin-marked transactions. run_test executes the new test.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 2821f

This change adds coverage for successful CoinJoin spending behavior without changing production code; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: thepastaclaw

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the new success-path CoinJoin test, its assertions, testing status, and scope.
Title check ✅ Passed The title clearly identifies the addition of success-path coverage for use_cj in rpc_coinjoin.py.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Codex/Sol only (Phase 2 disabled)

The exact-head diff adds focused success-path coverage for fully mixed CoinJoin inputs, change suppression, automatic selection, anonymized balance accounting, and the DS marker. Source inspection found no correctness or reliability defects, and rpc_coinjoin.py passed with both legacy and descriptor wallets; Python compilation and diff whitespace checks also passed.
Source: Codex reviewer backend model (exact model ID not supplied in the evidence); Claude verifier backend model (exact model ID not exposed in the runtime context). openclaw-agent/cliproxy/gpt-5.6-sol is orchestration-only and is not reviewer evidence.

Validated zero-blocker Codex/Sol precheck evidence was promoted to final because Phase 2 (Sonnet/Opus) is temporarily disabled. This is Codex/Sol-only final validation, not Codex + Sonnet/Opus coverage.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — dash-core-commit-history (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet/Opus: not run (Phase 2 disabled — temporary Codex/Sol-only final)
  • Secondary pass: disabled (temporary_phase2_sonnet_disable)

Comment thread test/functional/rpc_coinjoin.py Outdated
inputs = [{'txid': funding_txid, 'vout': out['n']} for out in funding_tx['vout'] if out['value'] == denom]
assert_equal(len(inputs), 2)

# Simulate mixing: a same-denomination, fee-free self-spend advances each

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's a good way to simulate mixing, I think. Let's make it a helper to use it in this functional test for other scenarios.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 2821f84. I extracted the round-advancing self-spend into a reusable simulate_mixing(...) helper and kept the scenario-specific funding and assertions in test_use_cj_success.


🤖 Posted autonomously by Codex on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit 0ea4bc6 into dashpay:develop Aug 23, 2026
37 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the test-use-cj-success branch August 23, 2026 15:25
@UdjinM6 UdjinM6 added this to the 24 milestone Aug 24, 2026
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.

4 participants