Skip to content

Add regression coverage for stream state boundaries - #1961

Open
samad13 wants to merge 2 commits into
LabsCrypt:mainfrom
samad13:test/stream-regression-coverage
Open

samad13 wants to merge 2 commits into
LabsCrypt:mainfrom
samad13:test/stream-regression-coverage

Conversation

@samad13

@samad13 samad13 commented Nov 23, 2026

Copy link
Copy Markdown

Description

Adds focused regression coverage for historical stream snapshots, integer validation, withdrawal depletion behavior, and summary-cache invalidation. It also rejects unsafe start-time integers and invalidates summaries after stream writes/indexed events.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Fixes #1742, Fixes #1738, Fixes #1744, Fixes #1743

Changes Made

  • Cover historical snapshot timestamp boundaries, invalid inputs, missing history, unknown streams, and dependency failures with public error-contract assertions.
  • Cover i128 upper bounds, zero values, decimal strings, and unsafe numeric inputs; reject unsafe numeric/string start times.
  • Cover withdrawal exact depletion, over-withdrawn states, persisted completed states, and simulation failures. The withdrawal route remains a documented dry-run and does not mutate indexed accounting.
  • Extract summary-cache handling and invalidate cached summaries after API writes and indexed stream events; test cache hits, expiry, and invalidation after stream creation.

Testing

  • cd backend && npx vitest run --coverage.enabled=false tests/stream.controller.test.ts tests/stream.validator.test.ts tests/integration/streams/withdraw.test.ts — passed (64 tests).
  • cd backend && npm run build — passed.
  • git diff --check — passed.
  • cd backend && npm run test:unit -- --coverage.enabled=false — 1,633 passed, 6 skipped, 2 unrelated token-route tests failed because Prisma token-registry reads returned 500 in this environment.
  • cd backend && npx eslint src/services/user-summary-cache.ts src/controllers/stream.controller.ts src/controllers/stream/cancel.ts src/workers/soroban-event-worker.ts src/validators/stream.validator.ts tests/stream.controller.test.ts tests/stream.validator.test.ts tests/integration/streams/withdraw.test.ts — passed with 0 errors; 5 existing warnings in unchanged any usages.
  • The full lint hook also encounters two existing errors in tests/token-registry.service.test.ts and tests/webhook-auth.test.ts; those unrelated files were left unchanged.

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

  1. Run the focused Vitest command above from backend/.
  2. Run npm run build from backend/.
  3. Run npm run test:unit -- --coverage.enabled=false from backend/ when the test database is available.

Breaking Changes

Breaking Changes:

  • None to route or response contracts. Unsafe timestamps that cannot be represented exactly are rejected.

Migration Guide:

Not applicable.

Screenshots/Demo

Not applicable.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Updated Postman/Hoppscotch API collections if routes changed
  • If routes or response shapes changed, ran the OpenAPI api-types drift check (npm run codegen:openapi in backend/, then npm run codegen:api-types in frontend/) and committed the regenerated flowfi.openapi.json / api-types.generated.ts
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable
  • If this change adds or modifies a metric, I have updated the Grafana dashboard and the alert rules in backend/docs/observability/

Additional Notes

The pre-existing local package-lock.json modification was intentionally excluded from this PR.

samad13 and others added 2 commits November 23, 2026 16:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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