feat(stellar): add Horizon mock server and fix pool sequence resync & tests. - #1890
Merged
sublime247 merged 1 commit intoAug 29, 2026
Merged
Conversation
|
@ShantelPeters 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Summary of Changes
This PR introduces an in-memory Horizon Mock Server with configurable chaos/outage controls, adds end-to-end integration tests for Horizon node failover & outage recovery, fixes sequence resynchronization in the Stellar Channel Account Pool, and resolves test suite suite dependencies across SEP-12 KYC & trustline modules.
🛠️ Key Improvements & Features
1. 🌐 Mock Horizon Server (
src/mocks/horizonMockServer.ts&scripts/horizon-mock-server.ts)/,/health,/accounts/:id,/accounts/:id/transactions,/transactions,/fee_stats,/paths/strict-receive,/ledgers).503_service_unavailable,500_internal_error,429_rate_limit,timeout,flaky,offline), latency injection (delayMs), andRetry-Afterheader simulations.npm run horizon-mock:devto run the standalone mock server locally for development.2. 🛡️ Network Outage & Failover Integration (
src/stellar/__tests__/horizonOutage.test.ts)HorizonPoolautomatic failover across nodes during503 Service Unavailable,500 Internal Error, and429 Rate Limitconditions.HorizonPool(src/stellar/horizonPool.ts) to allow HTTP URLs when running tests or in development (allowHttp).3. 🔄 Channel Account Pool Sequence Resync Fix (
src/stellar/pool.ts)submitWithChannelto update localaccount.sequence = newSequpon detecting sequence mismatches (tx_bad_seq), ensuring retry attempts use the updated sequence number.submitTransaction.4. 🔑 SEP-12 Rate Limiting & UserModel Integration (
src/middleware/rateLimit.ts&src/stellar/sep12.ts)sep12RateLimiterkey resolution to fallback to query/bodyaccountparameters or client IP when requests are unauthenticated.sep12.tsto preserveAppError.statusCodefor proper HTTP 400 validation error responses.UserModelinsep12.test.tsto prevent database lockups during unit testing.5. 🧪 Unit Test Normalization (
src/stellar/__tests__/)StellarSdk.Accountmock instantiations intrustlines.test.tsandpayments.test.ts.ChangeTrustoperations (1000.0000000,0.0000000) matchingStellarSdk7-decimal string normalization.🧪 Verification & Testing
Automated Test Results
186 / 186tests passed (100%)15 / 15tests passed (100%)npm run build(tsc) compiled cleanly with 0 errors.