Skip to content

Add unit tests for optimistic update rollback restoring correct holdings state on transaction failure #591

Description

@Chucks1093

Summary

The optimistic buy update modifies the React Query cache immediately on submission. If the transaction fails, the cache must be rolled back to the exact state before the optimistic write. Unit tests should confirm the rollback restores the previous holding quantity without leaving the cache in a partially updated state.

Scope

  • Seed the React Query cache with a holding of 2 keys for a creator
  • Trigger a buy for 1 key and apply the optimistic update (cache should show 3)
  • Simulate a transaction failure
  • Assert the cache is rolled back to 2 keys, not 3
  • Assert a second optimistic update after the rollback starts from the correct base of 2

Acceptance Criteria

  • Cache shows updated quantity during optimistic window
  • Cache rolled back to previous quantity on failure
  • Rolled-back state is exactly the pre-optimistic snapshot, not a re-fetch result
  • Subsequent optimistic updates after rollback use the correct base value

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions