Repository navigation
test: cover the contest precheck mapping and the masternode balance read - #1489
Conversation
Follow-up to #1476, whose review deferred two test gaps. The contest precheck mapped the vote-state answer inline, next to a query that reads the SDK from the host, so nothing could call it with a chosen answer. The mapping is now a pure function over the answer or its failure; the caller adds the deadline for an active contest as before. The masternode balance read called the SDK directly. It now takes the batch read as a parameter, so the three outcomes (credits, no identity, failed read) can be exercised without a network. No behavior change. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit e945eec) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
This follow-up adds eight unit tests for username contest status mapping and masternode balance reads, using two test seams without changing production behavior. At the reviewed head, the simulator suite, test-target membership check, workflow lint, and accessibility audit passed; the automated review check was still pending.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The diff adds two small test seams and focused unit coverage without changing the existing contest or balance-read behavior. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 82% left, weekly 59% left; passed overgemini-3.8-flash-high(lane failed) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/UsernameMarketplaceService.swift`:
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/UsernameMarketplaceService.swift:499-507: Precheck tests still pass if an active contest loses its known deadline
Impact: If the precheck drops a known deadline, users who otherwise qualify to request the name can still see Continue after the contest's join window has closed.
Losing a known deadline would let users proceed with a request Platform will refuse: Create Username blocks joining after the cutoff only when it has the contest's end time. The new tests exercise only `contestPrecheck(voteState:)` and expect `endsAt: nil` for active contests, so they stay green even if the refactored production branch stops attaching the deadline. Add a focused test that exercises that branch with a stubbed contest listing: verify that a millisecond timestamp under the normalized label becomes the returned `Date`, and that a missing entry or failed lookup keeps the contest active with no deadline.
| let precheck = Self.contestPrecheck(voteState: voteState) | ||
| guard case .activeContest(let contenders, _) = precheck else { return precheck } | ||
| // The vote-state payload carries no deadline, so ask the | ||
| // current-contests listing (normalized name → TimestampMillis) | ||
| // for it. Best-effort: a failed or incomplete listing just | ||
| // leaves the deadline unknown. | ||
| let endsAt = (try? await sdk.dpnsGetCurrentContests())?[normalized] | ||
| .map { Date(timeIntervalSince1970: Double($0) / 1000) } | ||
| return .activeContest(contenders: contenders, endsAt: endsAt) |
There was a problem hiding this comment.
🟡 Suggestion: Precheck tests still pass if an active contest loses its known deadline
Impact: If the precheck drops a known deadline, users who otherwise qualify to request the name can still see Continue after the contest's join window has closed.
Losing a known deadline would let users proceed with a request Platform will refuse: Create Username blocks joining after the cutoff only when it has the contest's end time. The new tests exercise only contestPrecheck(voteState:) and expect endsAt: nil for active contests, so they stay green even if the refactored production branch stops attaching the deadline. Add a focused test that exercises that branch with a stubbed contest listing: verify that a millisecond timestamp under the normalized label becomes the returned Date, and that a missing entry or failed lookup keeps the contest active with no deadline.
source: gpt-6.2-sol (phase2-reviewer: general)
…ail, drop diary tags Merge develop (#1489, #1487): the contest precheck failure line stays in the catch and writes only the error summary. Asset-lock retry failures keep the wallet error's detail on the retry line and in summary.txt (#1276), as a stated exception in ADR-0061: a recipient mismatch writes its fixed sentence, a consensus rejection its code and kind only, any other error no text. Test comments drop review-diary tags (guardrail 6); a source check keeps them out. The feature README says where a failed network switch's Platform address sync reason is in the export (the SDK session log). Co-Authored-By: Claude Opus 5.5 <[email protected]> SDD-Published-From: e994f3ccb9e6e4f9d89819d15f406e20182fe8e0
Issue being fixed or feature implemented
Follow-up to #1476. Its review deferred two test gaps:
UsernameMarketplaceService.contestPrecheck(label:)had no unit test. refactor: recognize Platform refusals by consensus code in one table #1476 made every query failure.unknown(which blocks "Continue" on the create-username screen), and the mapping could not be called withoutSwiftDashSDKHost.shared.sdk.MasternodeClaimableBalanceTestsfed dictionaries toresolvebut never exercised thefetchBalances(ids:)path that the masternode screens' balance and Withdraw button depend on.What was done?
Two minimal seams, no behaviour change:
UsernameMarketplaceService.contestPrecheck(voteState:): a pure function from the vote-state answer (or its failure) toContestPrecheck.contestPrecheck(label:)calls it and, as before, asks the current-contests listing for the deadline only when a contest is active. The pure function reports an active contest with no deadline.MasternodeClaimableBalance.fetch(identityId:fetchBalances:): the batch read is passed in.fetch(sdk:identityId:)hands itsdk.identities.fetchBalances(ids:).Tests:
UsernameContestPrecheckTests(5 tests): no contenders →.fresh;winner"LOCKED" →.locked;winneran identity id →.locked; contenders with no winner →.activeContestwith their count; a failed query →.unknown, including failures whose text reads "not found" / "no contest". Payloads go throughJSONSerialization, as in the SDK.MasternodeClaimableBalanceTests: credits, no identity (missing entry and entry with no balance), and a failed read let through as an error.How Has This Been Tested?
UsernameContestPrecheckTestsandMasternodeClaimableBalanceTestson a simulator, schemedashwallet-dashpay, Debug, arm64, platform at the pinned commit: 10 tests (8 new), 0 failed.scripts/ci/check_test_target_membership.pypasses.DashWalletTestssuite was not run locally.Not covered:
contestPrecheck(label:)still reads the SDK from the host: the missing-SDK →.unknownpath, label normalization, the query itself and the deadline lookup have no test.contenderskey maps to.fresh(the existing?? []). The FFI always writes that key, so this is neither pinned by a test nor changed.sdk.identities.fetchBalances(ids:)itself (missing identity = no entry, failure = thrown error) needs a network.fetchClaimableBalance()inMasternodesScreenandTrackedMasternodeDetailScreen, which turns the three outcomes into the balance, the message and the Withdraw button, has no test; both take the SDK from the host.Breaking Changes
None.
Checklist:
no significant decision🤖 Generated with Claude Code
Summary by CodeRabbit