Skip to content

test: add test suites for offline queue sync, concurrency, retry logic, and wallet integration - #1146

Open
Blackdavid1 wants to merge 1 commit into
Stellar-split:mainfrom
Blackdavid1:test/queue-concurrency-retry-wallets
Open

Blackdavid1 wants to merge 1 commit into
Stellar-split:mainfrom
Blackdavid1:test/queue-concurrency-retry-wallets

Conversation

@Blackdavid1

Copy link
Copy Markdown

What this fixes

This PR addresses four test and reliability issues:

  1. Test offline queue synchronization #1041 - Test offline queue synchronization: The offline queue lacked comprehensive test coverage for storage persistence, sync execution, conflict resolution (e.g. remote-wins resolution when an invoice was settled remotely), and state recovery.
  2. Test concurrent payment handling #1040 - Test concurrent payment handling: There was missing end-to-end test validation for concurrent payment operations, including multi-payment race condition resistance, transaction nonce handling, balance invariant preservation, and error isolation under load.
  3. Test transaction retry logic #1039 - Test transaction retry logic: There was no dedicated test suite ensuring retry behavior adheres to exponential backoff, jitter, maximum retry limits, and proper classification of retryable network errors (such as timeouts, connection resets, and 502/504 Bad Gateway / Gateway Timeout HTTP errors) versus non-retryable terminal errors.
  4. Integration tests for all wallet types #1038 - Integration tests for all wallet types: There were no end-to-end integration tests verifying cross-wallet compatibility across all supported Stellar wallet providers (Freighter, LOBSTR, xBull, Ledger, and WalletConnect) covering connection flows, transaction signing, account changes, disconnection events, and error cases (e.g., wallet not installed, user rejection, hardware disconnect).

What changed

  • Offline Queue Sync (Test offline queue synchronization #1041):

    • Added BigInt-safe serialization and deserialization for localStorage persistence.
    • Implemented sync(strategy) on OfflineQueue with conflict detection against remote invoice state and emitted queue:conflict:resolved events.
    • Added recoverState() to reconstruct queue from persistence storage.
    • Exposed syncOfflineQueue() and offline event definitions on StellarSplitClient.
    • Added complete test suite test/offlineQueue.test.ts with 12 tests covering queue storage, sync process, conflict resolution, and state recovery.
  • Concurrent Payment Handling (Test concurrent payment handling #1040):

    • Added comprehensive test suite test/concurrentPaymentHandling.test.ts (10 tests) validating simultaneous payments across multiple payers and invoices, sequential nonce assignment, balance conservation invariants, partial failure isolation, and race condition handling.
  • Transaction Retry Logic (Test transaction retry logic #1039):

    • Added HTTP status codes 502 and 504 to isRetryable in src/retryPolicy.ts.
    • Added comprehensive test suite test/transactionRetry.test.ts (18 tests) verifying exponential backoff calculations, randomized jitter bounds, timeout / network error retries, max retry thresholds, unretryable error classification, and abort signal handling.
  • Wallet Integration (Integration tests for all wallet types #1038):

    • Enhanced StellarSplitClient.connectWallet() to seamlessly handle both browser extension wallets with .connect() / .onAccountChange() and standard WalletAdapter instances using .getAddress().
    • Fixed uninitialized event collections in OptimisticCache to prevent iteration crashes during wallet payments.
    • Added comprehensive integration test suite test/walletIntegration.test.ts (19 tests) covering connection, signing, disconnection, account changes, and failure cases for Freighter, LOBSTR, xBull, Ledger, and WalletConnect.

Testing

Ran all newly created and related test suites using Vitest:

  • test/offlineQueue.test.ts (12 passed)
  • test/concurrentPaymentHandling.test.ts (10 passed)
  • test/transactionRetry.test.ts (18 passed)
  • test/walletIntegration.test.ts (19 passed)
  • test/retryPolicy.test.ts (31 passed)
  • test/optimisticCache.test.ts (12 passed)
  • test/walletSessionManager.test.ts (26 passed)
  • test/walletconnect.test.ts (14 passed)
  • test/ledgerAdapter.test.ts (6 passed)
  • test/freighterAdapter.test.ts (13 passed)
  • test/xbullAdapter.test.ts (7 passed)
    Total: 11 test files, 168 tests passed, 0 failures.

Issues

closes #1041
closes #1040
closes #1039
closes #1038

… wallet integration (Stellar-split#1041, Stellar-split#1040, Stellar-split#1039, Stellar-split#1038)

- Test offline queue synchronization with storage persistence, conflict resolution, and state recovery (Stellar-split#1041)
- Test concurrent payment handling with nonce management, balance invariants, and race condition prevention (Stellar-split#1040)
- Test transaction retry logic with backoff, jitter, network timeouts, 502/504 errors, and max retries (Stellar-split#1039)
- Integration tests for Freighter, LOBSTR, xBull, Ledger, and WalletConnect adapters (Stellar-split#1038)
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Blackdavid1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Development

Successfully merging this pull request may close these issues.

Test offline queue synchronization Test concurrent payment handling Test transaction retry logic Integration tests for all wallet types

1 participant