Repository navigation
test: cover indexer top-up/completion paths; fix labels and page state - #1940
Merged
K1NGD4VID merged 7 commits intoNov 21, 2026
Merged
Conversation
… label (LabsCrypt#632) The settings-tab "Create Stream" panel named its only control with `aria-label`, so there was no label element to anchor and no id for tests to target. Give the input an id plus an sr-only sibling label so the accessible name comes from a real association, with no layout change. The issue cites `dashboard-view.tsx:879` and recipient/token/amount at 922-934. That wizard moved and already pairs htmlFor with ids; the template-name input is the gap that remains in this form.
…ing (LabsCrypt#1085) Page shells duplicated a chain of ad-hoc booleans (hydrated? connected? loading? error? empty?) and each page ordered them slightly differently, so a finished-but-errored query could render the empty state. One hook derives the five mutually exclusive states in a documented priority order and the two pages that had drifted now consume it.
…ards (LabsCrypt#1761) The top-up handler recomputes the deposit, the derived end time and the pause-adjusted duration in one expression, and nothing tested the arithmetic: a regression in the divisor, the pause term or the i128 decode would have silently extended or shortened live streams. These tests drive processEvent, so they also pin the dedup guard, the missing-field rejections, the transaction rollback and the exact SSE payload.
…r time (LabsCrypt#1763) Completion writes the chain's total instead of accumulating withdrawals, which is the only place the two can disagree — and the dedup guard runs after the stream update, so a redelivery re-writes the row. Both behaviours were undocumented. These tests pin the override, the ledger-close timestamp precedence with its wall-clock fallback, and the sentinel failure that must not fail the event.
backend/tsconfig.json compiles tests/ with noUncheckedIndexedAccess and the frontend build type-checks its test files, so an unchecked [0] read and an unused React import each fail `npm run build` rather than the test run.
LabsCrypt#1932 moved the top-up writes behind applyToppedUpEvent, which takes the stream row lock through $executeRaw and selects only the columns it needs, and started storing the event timestamp as a BigInt. The fake client has to mirror that seam or the suite describes a shape the worker no longer has.
…ypt#1932 The API writer and the indexer share one dedup key, and the marker row the API leaves behind (ledgerSequence 0) is the only case where the indexer writes through a skip. Nothing pinned which of the two branches a given existing row takes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Four issues assigned to me, one branch, rebased onto
mainat5b93cc9.idand a real<label htmlFor>; the barearia-labelis gone. NewDashboardSettings.test.tsxasserts that association, then walks everyinput,textareaandselectin the rendered form so a future control without anidfails the gate.frontend/src/hooks/useAsyncPageData.tsreturns one derived view state (awaiting/error/loading/empty/ready, resolved in that priority order) from the fetch flags.activity-content.tsxandincoming-content.tsxboth consume it, so the two pages cannot drift apart. 11 hook tests (including an independent expectation over all 16 flag combinations) plus a new 7-test suite forincoming, which had none; the pre-existingsrc/__tests__/activity-content.test.tsxstill passes unchanged.backend/tests/stream-topped-up-rate.test.ts(26 tests) forstream_topped_up.backend/tests/stream-completed-event.test.ts(23 tests) forstream_completed, including the completion/withdrawal interleavings.Production code changed only in
DashboardSettings.tsxand the two page components. No config, lockfile, coverage threshold, or CI file was touched.What the two indexer suites pin
Both drive the public
worker.processEvent(event)entry point against a hoisted in-memoryprismafake with snapshot/rollback semantics, so the assertions are about stored rows, broadcast payloads and the thrown error contract rather than about internals.stream_topped_up(#1761):startTime + deposited / rate + totalPausedDurationfor a normal rate, a rate that leaves fractional runway (truncates toward zero), both halves of the i128, values pastNumber.MAX_SAFE_INTEGER, andrate = 0(null end time)ratePerSecondis the only rate input: the handler never rewrites it, and astream_rate_modifiedevent leaves it alonedepositedAmountand the oneTOPPED_UPStreamEventrow per top-uptxHashdoes not re-apply the amount, and a row the indexer already wrote (non-zero ledger position) stays untouchedledgerSequence = 0, the indexer writes through the skip, assigns the chain's absolute total rather than adding its own delta, and fills the ledger position into the existing row instead of writing a second oneamountornew_deposited_amountrejects withStreamToppedUp #<id>: missing body fieldsbefore any writestream_completed(#1763):total_withdrawnis assigned towithdrawnAmount(not added to it),isActivegoes false, oneCOMPLETEDrow keyed on txHash + eventType, ledger close time as the stampStreamrow rejects before the dedup guard, and an event-row write failure rolls the whole transaction backBehaviour found while characterising these paths
Not changed here. Each one is asserted as current behaviour so that a future change is a deliberate one.
stream_topped_upcarriesnew_end_time(StreamToppedUpEventincontracts/stream_contract/src/events.rs) and the worker ignores it, deriving the value inprojectedEndTime. Derivation is the single-writer design from fix(backend): one top-up writer, honest status codes, one envelope #1932, so this is a question rather than a bug report: if the contract's projection and the backend's ever disagree, the UI shows the backend number and nothing alerts.handleStreamToppedUpstampsMath.floor(Date.now() / 1000)while every other handler in the file stampsgetEventLedgerTimestamp(event). Two clocks, one column, so a replay or backfill writes a different timestamp than the live pass did.processEvent's switch has no case forstream_refueled(StreamRefueledEvent) orstream_rate_modified(StreamRateModifiedEvent). Both fall throughdefault:and are dropped silently, even though the contract emits them.handleStreamCompletedperforms itsstream.updatebefore the dedup guard and broadcasts SSE after the transaction returns, so a replayed completion re-writes the row and re-notifies connected clients even though it correctly does not duplicate the event row.tokens_withdrawnincrementswithdrawnAmount;stream_completedassigns it. If a withdrawal is indexed after the completion (RPC retry or replay of an earlier transaction), the stored total ends up above the chain-authoritative one - the test that pins this lands on1600for a stream whose on-chain total is1000.#632's file citation is stale
The issue points at
frontend/src/components/dashboard/dashboard-view.tsxlines 879 and 922-934. That file no longer contains a single<label>: the wizard it describes was split intofrontend/src/components/stream-creation/, and those steps (RecipientStep,AmountStep,ScheduleStep,TemplateStep,TopUpModal,BatchStreamWizard) already pairhtmlForwithid. Of the controls the issue enumerates, the only one still unlabelled today is the template-name input in the settings tab, which is what the first commit fixes.BatchStreamWizarddoes have per-row inputs in table cells with no label element; that is a different form, so it is left alone here.Gates
Ran the job set that
.github/workflows/ci.ymltriggers for afrontend/**+backend/**diff, on Node 22.23.3 (.nvmrcsays 22), against a throwaway Postgres on127.0.0.1:55443using the workflow's ownDATABASE_URLshape. Each command ran unpiped with its exit code captured:New files individually:
stream-topped-up-rate.test.ts26 passed,stream-completed-event.test.ts23 passed,useAsyncPageData.test.tsx11 passed,incoming-content.test.tsx7 passed,DashboardSettings.test.tsx3 passed.Proof that the new tests can fail
Eleven regressions were injected one at a time into the code the two backend suites cover; every one was killed, and
git diff -- srcwas empty afterwards:projectedEndTimedropstotalPausedDurationprojectedEndTimereturnsstartTimeinstead ofnullat zero ratelockStreamForUpdatecall removed from the top-up pathprojectedEndTimereturns a constant, i.e. trusts the chainNotes for review
mainwhile this branch was in progress. It is rebased onto5b93cc9, no merge commit. Because the top-up suite goes throughprocessEvent, it absorbed theapplyToppedUpEvent/lockStreamForUpdaterefactor rather than being rewritten: the fake now answers$executeRawfor the row lock, honours Prismaselect, and expects aBigIntevent timestamp.tests/integration/*(whole-tabledeleteMany()whilepool: 'forks'runs other files in parallel). I proved it on an untouchedmaincheckout with none of my files present (3 failures) and dropped my own scoping commit once fix(backend): one top-up writer, honest status codes, one envelope #1932 shipped the same fix upstream.backendbuild andsoroban_simulation_errors.test.tswere red one4f4b5c(19tscerrors, 2 vitest failures). That is fixed upstream in5b93cc9; nothing in this branch touches that file.Closes #632
Closes #1085
Closes #1761
Closes #1763