fix(tests): correct stale stake-pool fixtures and program-id mocks - #2452
fix(tests): correct stale stake-pool fixtures and program-id mocks#2452dcccrypto wants to merge 3 commits into
Conversation
Second slice of the 65 CI failures #2450 exposed. Fixes 8, adds 2. All three files mocked a contract the hooks stopped using: 1. Wrong account layout. The fixtures packed lpMint@65 / vault@97 / cooldownSlots@162, which matches no decoder. `decodeStakePoolV1` reads 104 / 136 / 184 — independently corroborated by `parseStakePool` in app/app/api/stake/pools/route.ts, the route that reads live pools. The mint/vault reads still yielded *a* PublicKey (any 32 bytes are valid) and unpackMint/unpackAccount are mocked to fixed balances regardless of which account was fetched, so the balance and share tests were passing vacuously — only the cooldown fields, actually read as numbers, showed it. 2. Wrong stake program. The by-pool hooks resolve it from getConfig().vaultProgramId, not the SDK's getStakeProgramId(). The tests still owned the pool account with the SDK's old devnet id, so every run tripped the owner-mismatch guard. That also explains the "resolveFirst is not a function" double-submit failures: the first deposit threw before reaching sendTx, so mockImplementationOnce never ran. Dropped the now-dead SDK mocks (STAKE_PROGRAM_ID, getStakeProgramId, STAKE_POOL_SIZE, decodeStakePool) and let the real decodeStakePoolV1 run against a correctly-built buffer, so the fixtures are checked by a real decoder rather than a stub. Adds a deliberate test for the owner-mismatch guard on both by-pool hooks — it was being tripped accidentally by every test but asserted by none. Verified non-vacuous: disabling the guard fails it, restoring it passes. Test files only, no product change. 95 -> 87 failures on this branch, tsc --noEmit clean, no stake test still failing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
The 2026-07 fee-split merge made lib/v17-engine-config.ts import
V17_MARKET_GROUP_OFF from @percolatorct/sdk. The stake hooks pull that in
transitively, so the two by-pool stake test files' SDK mock must now define it
or the module fails to load ("No V17_MARKET_GROUP_OFF export ... Did you forget
to return it from vi.mock"). Adds the export; all 3 stake suites green (28).
|
Closing as superseded — this landed upstream independently. The test-maintenance batch merged into Verified on the current base rather than assumed:
Rebasing it would produce a no-op at best, so closing rather than leaving a stale PR in the queue. For what it's worth the remaining 14 failures are covered by the three PRs I'm keeping open: #2451 (useWallet + ConnectButton, 7), #2459 (Header nav, 4), #2458 (Portfolio PORT-007, 1). With those three stacked the suite is 2823 passed, 0 failed. |
Second slice of the 65 failures #2450 exposed (first was #2451). Fixes 8, adds 2. Test files only — no product change.
Two stale mocks, one cluster
1. The fixtures used an account layout no decoder reads. They packed
lpMint@65/vault@97/cooldownSlots@162.decodeStakePoolV1reads104/136/184— corroborated independently byparseStakePoolinapp/app/api/stake/pools/route.ts, the route that reads live pools. So the hook was right and the fixture was wrong.Worth noting why only the cooldown tests failed: the mint/vault reads still produced a valid
PublicKey(any 32 bytes are), andunpackMint/unpackAccountare mocked to fixed balances regardless of which account was fetched. The balance and user-share tests were passing vacuously. OnlycooldownSlots/depositCap, actually read as numbers, surfaced the mismatch.2. The pool was owned by the wrong program. The by-pool hooks resolve the stake program from
getConfig().vaultProgramId, not the SDK'sgetStakeProgramId(). The tests still owned the pool account with the SDK's old devnet id, so every run tripped this guard:That also explains the odd
TypeError: resolveFirst is not a functionin the double-submit tests — the firstdeposit()threw before reachingsendTx, somockImplementationOncenever ran and the resolver was never assigned. One root cause, two symptoms.What changed
@/lib/configmocked sovaultProgramIdand the pool account's owner are pinned to the same keySTAKE_PROGRAM_ID,getStakeProgramId,STAKE_POOL_SIZE,decodeStakePool) and let the realdecodeStakePoolV1run — the fixture is now validated by a real decoder instead of a stubEvidence
npx tsc --noEmitcleanStacks cleanly with #2451 — different files, both based on
playground.🤖 Generated with Claude Code