Skip to content

fix: resolve lost-update race condition in top-up endpoint - #1358

Open
composure-lad wants to merge 2 commits into
LabsCrypt:mainfrom
composure-lad:fix/issue-1295
Open

fix: resolve lost-update race condition in top-up endpoint#1358
composure-lad wants to merge 2 commits into
LabsCrypt:mainfrom
composure-lad:fix/issue-1295

Conversation

@composure-lad

Copy link
Copy Markdown

This PR fixes Functional Edge Case #15 (lost-update race condition in top-ups) and adds the requested concurrent integration test as specified in the audit.

  • Replaced JS-level calculation with an atomic SQL update via $queryRaw
  • Added handles concurrent top-ups correctly without lost updates test to backend/tests/integration/top-up.test.ts

Closes #1295

Closes LabsCrypt#1295

Replaced non-atomic application-level balance updates with an atomic Prisma $queryRaw statement to ensure concurrent top-up requests don't overwrite each other's state changes. Added a concurrent test to verify.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Audit] No test covers the top-up lost-update race condition

1 participant