test: improve CoinJoin unit coverage#7380
Conversation
…empool re-entry Adds focused unit tests for behaviors the server/client mixing paths depend on but which were not previously exercised: - CCoinJoinEntry::AddScriptSig: matching prevout + sequence copies scriptSig and sets fHasSig; duplicate signature for the same input is rejected without overwriting; wrong prevout or wrong sequence is rejected; with multiple inputs only the matching one mutates. - CoinJoinQueueManager: HasQueueFromMasternode honors fReady; TryHasQueueFromMasternode finds by outpoint only; TryCheckDuplicate flags exact duplicates and same-masternode/same-readiness re-broadcasts but allows different readiness or a different masternode. - CDSTXManager: TransactionAddedToMempool clears the confirmed height set by BlockConnected (reorg/re-entry path); a mempool event for an unrelated tx does not mutate the stored DSTX. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
|
This pull request has conflicts, please rebase. |
WalkthroughThe PR adds unit tests for CoinJoin-related behavior. It covers DSTX entries when transactions re-enter the mempool after confirmation, Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
CI note: all real Dash build/test jobs are green on |
|
✅ Review complete (commit 873b14e) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Test-only PR adding focused unit coverage for CCoinJoinEntry::AddScriptSig, CoinJoinQueueManager queue lookup/duplicate semantics, and CDSTXManager mempool re-entry. All assertions verified against the implementations in src/coinjoin/coinjoin.cpp. Both reviewers converged on no findings; spot-checks of AddScriptSig, TryHasQueueFromMasternode, TryCheckDuplicate, TransactionAddedToMempool, and BlockConnected confirm the tests assert real behavior. Clean single conventional commit.
Note: GitHub does not allow me to approve my own PR, so this clean review is posted as COMMENT.
test: improve CoinJoin unit coverage
Issue being fixed or feature implemented
Improves Dash-specific CoinJoin unit test coverage with focused behavioral tests
for existing mixing support code. This follows up on the coverage review that
identified
src/coinjoinas one of the weakest Dash-specific areas.Tracker: https://github.com/thepastaclaw/tracker/issues/1592
What was done?
Added unit coverage for behavior used by CoinJoin server/client flows:
CCoinJoinEntry::AddScriptSignow covers matching by prevout and sequence,duplicate rejection without overwrite, wrong prevout/wrong sequence rejection,
and multi-input isolation.
CoinJoinQueueManagernow covers masternode queue lookup semantics, includingreadiness-aware lookups and duplicate detection for same masternode plus same
readiness.
CDSTXManagernow covers clearing confirmed height when a tracked DSTXre-enters the mempool and ignoring mempool events for unrelated transactions.
This deliberately avoids superficial enum/string/status tests and does not add
production hooks or fake network harnesses.
Coverage impact
Historical baseline from the published Dash Core coverage snapshot for
developata59ad9e8b:https://thepastaclaw.github.io/dash-coverage/2026-06-25-develop-a59ad9e8b/.
Old CoinJoin coverage from that snapshot:
src/coinjoinwas 464 / 2524 lines (18.4%) and 176 / 453 functions(38.9%).
src/coinjoinwas 695 / 2524 lines (27.5%) and 237 /453 functions (52.3%).
Measured targeted lcov comparison for this PR:
8c9f166a3da637ed4eb667731f5017a2cc8c33a6.873b14e9558ac8d9c11d031504083853b5d30678../configure --enable-lcov --without-gui --disable-bench --with-daemon --with-cli --disable-stacktraces --without-libs../src/test/test_dash --run_test=coinjoin_inouts_tests,coinjoin_queue_tests,coinjoin_dstxmanager_tests.errors.
Raw lcov totals from those targeted runs:
src/coinjoin/coinjoin.cpp: 105 / 302 lines (34.8%) and 23 / 41 functions(56.1%) on base; 133 / 302 lines (44.0%) and 28 / 41 functions (68.3%) on
head.
src/coinjoin: 214 / 2911 lines (7.4%) and 88 / 673 functions(13.1%) on base; 261 / 2930 lines (8.9%) and 105 / 685 functions (15.3%) on
head.
The aggregate denominator differs from the published full-suite snapshot because
this measurement is a local targeted lcov run as emitted by
llvm-cov gcov,including the header records present in that trace. The
coinjoin.cppnumbersare the directly comparable source-file movement from the PR's focused tests.
How Has This Been Tested?
Ran locally on macOS arm64 after building
src/test/test_dashin an isolatedworktree:
Result: 18 test cases, no errors detected.
Pre-PR review gate:
Result:
ship.Breaking Changes
None. Test-only change.
Checklist
code-owners and collaborators only)