fix(wallet-lib): fix broadcast retry not matching DAPI error message#3434
Conversation
The wallet-lib retry logic for UTXO conflicts checked for an exact
match against 'invalid transaction: bad-txns-inputs-missingorspent',
but DAPI (both JS and Rust) returns 'Transaction is rejected:
bad-txns-inputs-missingorspent'. The retry never triggered, causing
faucet wallet funding to fail when UTXOs were still in the mempool.
This caused 7 nightly test failures since ~Mar 16: 1 Data Contract
funding failure + 6 cascading Contacts test failures.
Fix: use .includes('bad-txns-inputs-missingorspent') which matches
regardless of the message prefix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR updates documentation for a known test failure issue related to transaction broadcast errors and implements the corresponding code fix. The error handling logic is made more robust by changing from exact string matching to substring matching to properly trigger retry behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Review GateCommit:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@NIGHTLY_STATUS.md`:
- Around line 40-42: Update the inconsistent test summary by replacing the
outdated phrase "2 of 65 tests fail" with the current result "65 tests pass, 7
fail (1 Data Contract funding + 6 Contacts cascade)" so the line currently
showing "2 of 65 tests fail" matches the detailed report that now states "65
tests pass, 7 fail"; ensure the summary text exactly mirrors that detailed
status.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 14492381-a49f-46f3-819c-7e920c00c18d
📒 Files selected for processing (2)
NIGHTLY_STATUS.mdpackages/wallet-lib/src/types/Account/methods/broadcastTransaction.js
| Seven tests fail because Core rejects faucet wallet funding transactions whose inputs are already in the mempool. The failures are in the Data Contract and Contacts test groups -- 1 `before all` hook failure cascades into 6 dependent Contacts tests. | ||
|
|
||
| - **63 tests pass**, 2 fail | ||
| - **65 tests pass**, 7 fail (1 Data Contract funding + 6 Contacts cascade) |
There was a problem hiding this comment.
Inconsistent test counts with line 21.
Line 21 still states "2 of 65 tests fail" while line 42 now says "65 tests pass, 7 fail". These should be reconciled to avoid confusion.
📝 Suggested fix for line 21
-| [Test Suite](https://github.com/dashpay/platform/actions/workflows/tests-test-suite.yml) (`test:suite`) | **Failing** | 2 of 65 tests fail with `bad-txns-inputs-missingorspent`. See [known issues](`#test-suite-bad-txns-inputs-missingorspent-since-mar-16`). |
+| [Test Suite](https://github.com/dashpay/platform/actions/workflows/tests-test-suite.yml) (`test:suite`) | **Failing** | 7 of 72 tests fail with `bad-txns-inputs-missingorspent`. See [known issues](`#test-suite-bad-txns-inputs-missingorspent-since-mar-16`). |🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@NIGHTLY_STATUS.md` around lines 40 - 42, Update the inconsistent test summary
by replacing the outdated phrase "2 of 65 tests fail" with the current result
"65 tests pass, 7 fail (1 Data Contract funding + 6 Contacts cascade)" so the
line currently showing "2 of 65 tests fail" matches the detailed report that now
states "65 tests pass, 7 fail"; ensure the summary text exactly mirrors that
detailed status.
Issue Being Fixed
Since ~March 16, 7 nightly test suite tests fail consistently with
bad-txns-inputs-missingorspent. This has been tracked in NIGHTLY_STATUS.md.Root cause
The wallet-lib has retry logic for UTXO conflicts in
broadcastTransaction.js:181, but the error message check was wrong:The retry never triggered. When the faucet wallet tried to fund multiple test wallets in quick succession, the second transaction would reference UTXOs still in the mempool from the first — Core rejects with
bad-txns-inputs-missingorspent, and without the retry, the test fails immediately.Failing tests (7 total, from 2 broadcastTransaction failures)
Platform > Data Contract > "before all" hook— faucet funding fails2-7.
e2e > Contacts > Alice/Bob— cascade from Alice's wallet funding failureInvestigation timeline
What was changed
packages/wallet-lib/src/types/Account/methods/broadcastTransaction.jsUsing
.includes()matches regardless of the message prefix ("invalid transaction:","Transaction is rejected:", or any future format). Theerror.message &&guard prevents TypeError on errors without a message property.NIGHTLY_STATUS.md— Updated the known issue section with correct failure count (7, not 2), correct root cause (faucet funding, not withdrawals), and a link to this PR.Breaking Changes
None. The retry behavior is strictly more permissive (matches errors it previously missed).
Tests
The fix should resolve the 7 nightly test failures. The retry logic itself doesn't have a unit test in
broadcastTransaction.spec.js.🤖 Generated with Claude Code
Summary by CodeRabbit