Skip to content

fix: add stream_count view fn and fix resume_stream status#964

Open
Anthony-19 wants to merge 1 commit into
LabsCrypt:mainfrom
Anthony-19:main
Open

fix: add stream_count view fn and fix resume_stream status#964
Anthony-19 wants to merge 1 commit into
LabsCrypt:mainfrom
Anthony-19:main

Conversation

@Anthony-19

Copy link
Copy Markdown
Contributor

Closes #421

  • Add stream_count() read-only function that returns the global StreamCounter value (monotonically increasing, equals the highest stream ID ever issued, never decrements on cancel/complete).
  • Returns 0 on a freshly-deployed contract with no streams.
  • Add TypeScript binding fetchStreamCount() in frontend/src/lib/soroban.ts that simulates the view call without wallet auth.
  • Unit tests: stream_count_returns_zero_on_fresh_contract, stream_count_increments_by_one_per_create, stream_count_is_not_decremented_by_cancel, stream_count_matches_last_stream_id.

Closes #787

  • resume_stream now checks stream.status == Paused (not just stream.paused), so a stream cancelled while paused (status=Cancelled, paused=true) correctly returns StreamInactive instead of being resurrected to Active.
  • cancel_stream now explicitly clears stream.paused = false and stream.paused_at = None when settling a cancellation, ensuring no stale pause state survives into the Cancelled record.
  • Unit tests: resume_after_cancel_while_paused_returns_stream_inactive, cancel_while_paused_clears_pause_fields, cancel_normal_stream_also_clears_pause_fields.

… guard

Closes LabsCrypt#421 — stream_count() -> u64
- Add stream_count() read-only function that returns the global
  StreamCounter value (monotonically increasing, equals the highest
  stream ID ever issued, never decrements on cancel/complete).
- Returns 0 on a freshly-deployed contract with no streams.
- Add TypeScript binding fetchStreamCount() in frontend/src/lib/soroban.ts
  that simulates the view call without wallet auth.
- Unit tests: stream_count_returns_zero_on_fresh_contract,
  stream_count_increments_by_one_per_create,
  stream_count_is_not_decremented_by_cancel,
  stream_count_matches_last_stream_id.

Closes LabsCrypt#787 — resume_stream status guard
- resume_stream now checks stream.status == Paused (not just stream.paused),
  so a stream cancelled while paused (status=Cancelled, paused=true) correctly
  returns StreamInactive instead of being resurrected to Active.
- cancel_stream now explicitly clears stream.paused = false and
  stream.paused_at = None when settling a cancellation, ensuring no stale
  pause state survives into the Cancelled record.
- Unit tests: resume_after_cancel_while_paused_returns_stream_inactive,
  cancel_while_paused_clears_pause_fields,
  cancel_normal_stream_also_clears_pause_fields.
@ogazboiz

ogazboiz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

heads up: main's ci was broken (the Backend CI and Backend Docker Image CI jobs) until the fixes in #969 and #974 just landed, so the red backend/docker checks on this pr are almost certainly stale, they ran against the broken main. please rebase to re-test against the now-green main: git fetch origin && git rebase origin/main && git push --force-with-lease. once it's green i'll review and merge. (if a non-backend check like Frontend CI is still red after the rebase, that part is a real issue worth a look, since frontend ci was passing on main.)

@ogazboiz ogazboiz mentioned this pull request Jul 4, 2026
19 tasks
@ogazboiz

ogazboiz commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

the stream_count() + the resume_stream pause-state guard look fine, the red is in untouched files (worker Prisma export, deprecated.test.ts), stale base. rebase: git fetch origin && git rebase origin/main && git push --force-with-lease. two things: (1) this duplicates #433's stream_count() fn, please reconcile with that pr or one of you close, and (2) it's coming from your fork's main branch, use a descriptive feature branch next time so ci associates cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants