TimeCurveProtocolWarbowRefreshSection: missing Vitest coverage for permissionless write path #175
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega#175
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: P4 — test coverage
split out of #160 follow-up per @PlasticDigits — "all of these findings need to have issues opened for them".
context
TimeCurveProtocolWarbowRefreshSection.tsx(frontend/src/pages/timecurve/) is a permissionless write path covering candidate-load + on-chain podium refresh. landed viaa648283(#160 / EcoStrategy M-04) plusfff7946(#170 P3 polish) plus #170 follow-up adjustments.no Vitest test file exists for this component at HEAD
284c15c:sister flows in the same directory have tests (
TimeCurveSimplePodiumSection.test.tsx,TimeCurveStakeAtLaunchSection.test.tsx,TimeCurveSubnav.test.tsx).why it matters
permissionless write path with non-trivial state machine — fresh-load reset, pagination accumulation,
distinct_sql_cap_hitOR-aggregation across pages, dedup vs podium hints + connected wallet, sale-ended early return, wrong-chain barrier, error UX. exactly the kind of surface where regressions ride in via unrelated refactors.related #160 follow-up findings (separate tickets): #173 cosmetic double-call, #174 silent truncation, #172 CRITICAL gas-blowup design. each of these would benefit from regression coverage that does not exist today.
suggested coverage
minimum useful set:
loadFromIndexerhappy path: paginates acrossnext_offset, accumulates candidates, sets extras (apiTotal, podiumHintCount, distinct_sql_cap_hit OR-folded across pages)loadFromIndexerindexer-returns-null branch (line 102): clears candidates + extras, sets loadErrloadFromIndexerexception branch (line 131):friendlyRevertFromUnknown(e), candidates + extras clearedloadFromIndexermalformedchunk.candidates(non-array): does not throw, ends with empty load + appropriate error state (covers #174 + the Array.isArray hardening if it lands)loadFromIndexerreset-on-fresh-load: prior successful state cleared at top of new load (relevant when #160 finding 2 / "P3 reset-on-reload" lands)runRefreshsale-ended branch: early return with #149 messagerunRefreshchain-mismatch branch: early return with helper message, single invocation ofchainMismatchWriteMessage(covers #173 once that fix lands)runRefreshno-candidates branch: prompt to load firstrunRefreshhappy path:warBowRefreshCandidateAddressescalldata,writeContractAsyncinvocation, refetch hooks called on successacceptance criteria
frontend/src/pages/timecurve/TimeCurveProtocolWarbowRefreshSection.test.tsxcd frontend && npm test -- --runpasses including new fileorigin
split from #160 follow-up notes ("P4 — no Vitest unit/component test ships with the new section"). filing now per @PlasticDigits.
sister flow
useTimeCurveArenaModel.tsx:2615-2641is similarly untested per the original note. that is a separate scope and not covered by this ticket.cc @PlasticDigits
mentioned in issue #176
mentioned in issue #160
mentioned in merge request !377
mentioned in merge request !378
@PlasticDigits — did a deep-dive on the test scope before writing any code. surfaced one finding worth surfacing before i commit to a path.
the finding
there is no in-repo precedent for testing a wagmi-coupled component. every existing
.test.tsxusesrenderToStaticMarkup(server-side, no hooks). zero hits forvi.mock("wagmi",@testing-library/react, or@vitest-environmentper-file switches across the whole frontend.closest analogue is
referralRegisterWalletSession.test.ts:16-22which mocks ONE function fromwagmi/actions.TimeCurveProtocolWarbowRefreshSectionwould need the full wagmi hook surface (useAccount,useChainId,useReadContracts,useWriteContract) pluswagmi/actions.waitForTransactionReceiptplus thewriteContractWithGasBufferhelper plus a per-file env switch tohappy-domorjsdomto fire button clicks. that's net-new test infrastructure for this codebase.branch inventory at HEAD
efb6e0bloadFromIndexer(lines 91-141) — 9 distinct branches: happy single-page, happy multi-page pagination + apiTotal/podiumHintCount captured on first chunk + capHit OR-aggregated, indexer-returns-null, malformed candidates non-array, pagination guard cap at 50, throw-in-loop with friendlyRevertFromUnknown, finally-clears-loading, undefined-vs-null next_offset both break, empty-pages-after-success.runRefresh(lines 143-191) — 8 distinct branches: saleEnded short-circuit (#149), chain-mismatch short-circuit, address-undefined short-circuit, wbReads-not-loaded short-circuit, no-candidates-loaded short-circuit, happy submit with calldata + softCap 12_000_000n + onEstimateRevert "rethrow" + waitForTransactionReceipt + dual refetch, write rejection with friendlyRevertFromUnknown, useEffect-clears-txErr-on-chain-correction.plus 6 render-side branches (warbowPodiumFinalized fallback, idxExtras conditional rows, saleEnded placeholder, refresh button disabled cascade, load button label flip, error StatusMessage variants).
20 test cases mapped end-to-end. 7-8 reachable today via
renderToStaticMarkup. the rest depend on testing-library + dom env, OR a refactor.three paths
(A) refactor. extract
loadFromIndexerandrunRefreshinto pure dependency-injected helpers in a sibling.tsfile (deps:fetchTimecurveWarbowRefreshCandidates,writeContractWithGasBuffer,waitForTransactionReceipt, the friendly-error helper, etc.). component file becomes thinner — just hook glue + render. unit-test the helpers likewriteContractWithGasBuffer.test.tsdoes. consistent with existing patterns. no new dev dependencies. larger PR diff, but adjacent code stays clean.(B) add testing infrastructure. install
@testing-library/react, set per-file env via// @vitest-environment happy-dom, mock the full wagmi hook surface in one block, write component-integration tests. smaller diff, but introduces a new testing pattern that diverges from the rest of the repo. one new dev dependency.(C) defer. park #175 until either path A or B comes up naturally. ticket stays open as a known coverage gap. P4 severity supports this.
my read
(A) is the cleanest fit — same idiom as
writeContractWithGasBufferwhich we just landed in !378. extracted helpers are reusable for future work and trivial to mock at the boundary. (B) introduces test-shape divergence in the codebase. (C) is fine if you want to push #175 down the priority list, but worth flagging that the ticket as filed assumed (B) shape.happy to ship (A) — would land as a refactor MR (component split + helpers + ~12-15 helper unit tests + ~7-8 render tests for the component shell). ETA reasonable from here. flag if you'd rather (B) or (C).
Closing as we are redesigning the warbow podium to be set by trusted governance instead of onchain due to issues from warbow point decreases