✅ All 32 tests passing
npm test| Category | Tests | Status |
|---|---|---|
| enqueue | 4 | ✅ Pass |
| updateTxHash | 2 | ✅ Pass |
| markConfirmed | 2 | ✅ Pass |
| markFailed | 7 | ✅ Pass |
| retry | 3 | ✅ Pass |
| purge | 2 | ✅ Pass |
| pendingCount | 4 | ✅ Pass |
| localStorage persistence | 5 | ✅ Pass |
| cleanup on unmount | 1 | ✅ Pass |
| state transitions | 2 | ✅ Pass |
| TOTAL | 32 | ✅ Pass |
- ✓ should add a new transaction with default maxRetries of 5
- ✓ should add a new transaction with custom maxRetries
- ✓ should not add duplicate transactions
- ✓ should add transactions at the beginning of the queue
- ✓ should update txHash and set status to submitted
- ✓ should not affect other transactions
- ✓ should mark transaction as confirmed
- ✓ should cleanup any pending retry timer
- ✓ should mark transaction as failed with error message
- ✓ should schedule auto-retry with 1s delay on first failure
- ✓ should schedule auto-retry with 5s delay on second failure
- ✓ should use exponential backoff delays [1s, 5s, 15s, 30s, 60s]
- ✓ should cap delay at 60s for retries beyond 5th
- ✓ should not schedule retry when maxRetries is reached
- ✓ should cleanup old timer before scheduling new one
- ✓ should manually reset transaction to pending and increment retryCount
- ✓ should cleanup any pending auto-retry timer
- ✓ should work on transactions with any status
- ✓ should clear all transactions from queue
- ✓ should clear all pending timers
- ✓ should count transactions with pending status
- ✓ should count transactions with submitted status
- ✓ should not count confirmed or failed transactions
- ✓ should update when transactions change status
- ✓ should persist queue to localStorage on changes
- ✓ should restore queue from localStorage on mount
- ✓ should handle corrupt localStorage data gracefully
- ✓ should handle missing localStorage gracefully
- ✓ should update localStorage when purging
- ✓ should clear all timers on unmount
- ✓ should follow correct state flow: pending → submitted → confirmed
- ✓ should follow retry flow: pending → failed → pending (auto) → failed (final)
npx tsc --noEmitResult: No errors
npm run buildResult: Build successful
- Compiled successfully in 8.7s
- TypeScript finished in 7.6s
- Static pages generated successfully
src/hooks/useRetryQueue.ts: No diagnostics foundtests/hooks/useRetryQueue.test.ts: No diagnostics found
- Duration: 3.69s
- Transform: 169ms
- Setup: 263ms
- Import: 565ms
- Tests: 214ms
- Environment: 2.16s
- States: pending → submitted → confirmed | failed
- All state transitions working correctly
- Adds new transactions with retryCount: 0
- Sets status: "pending"
- Default maxRetries: 5
- Transitions to "submitted" status
- Updates transaction hash
- Finalizes transaction as confirmed
- Cleans up pending timers
- If retryCount < maxRetries: schedules auto-retry
- Uses exponential delays: [1s, 5s, 15s, 30s, 60s]
- Else: marks as failed permanently
- Manually triggers immediate retry
- Cancels scheduled retries
- Increments retry count
- Clears all pending timers and state
- Resets localStorage
- useRef<Map<string, setTimeout>> for active retry timers
- Cleanup on unmount
- No memory leaks
- Queue persisted across browser reloads
- Serialization/deserialization working correctly
- Handles corrupt data gracefully
- Delays: [1s, 5s, 15s, 30s, 60s]
- Capped at 60s
All requirements have been successfully implemented and verified:
- ✅ 32/32 tests passing
- ✅ TypeScript compilation successful
- ✅ Next.js build successful
- ✅ No linting or diagnostic errors
- ✅ All requirements met
- ✅ Production-ready code
The useRetryQueue hook is fully functional and ready for use in production.