Repository navigation
test: add unit tests for sequence cache, account lock, progress tracker, auth attempt tracker - #749
Merged
DeFiVC merged 4 commits intoOct 21, 2026
Conversation
added 4 commits
October 21, 2026 18:50
…ial#589) Covers lock acquisition/release on success and on a thrown error, serialization of concurrent calls for the same account, independent execution for different accounts, and the configured timeout.
…l#590) Covers getOnChainContentHash hash retrieval, missing contract config, simulation errors/missing retval/non-string decode, and RPC failures.
…ficial#598) Add coverage for lockout expiration (ttl 0 and the missing-key -2 case) and for checkAuthLockout reporting not-locked-out again after clearAuthFailures runs.
|
@uche001-dev 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
Adds (and in one case expands) unit test coverage for four previously-untested or thinly-tested modules: the Stellar sequence cache, the account-lock utility, the on-chain progress-tracker read, and the auth attempt tracker's lockout-expiration path.
closes #588
closes #589
closes #590
closes #598
Changes
#588 - Sequence cache (
src/stellar/sequence-cache.ts)New
tests/unit/stellar/sequence-cache.test.ts. Covers:getNextSequence()cache hit (RedisEXISTStrue, atomic increment)falseand asnullfrom the Lua script, falling back to Horizon viastellarClient.getAccountand seeding with the account's current sequenceSEED_AND_INCREMENT_SCRIPTNX-collision case where another process seeds firstinvalidate()deleting the key, writing an audit log entry, and not throwing when the audit log call rejectsresetTo()setting the key with the configured TTL#589 - Account lock utility (
src/utils/account-lock.ts)New
tests/unit/utils/account-lock.test.ts. Covers:#590 - Progress tracker (
src/stellar/progress-tracker.ts)New
tests/unit/stellar/progress-tracker.test.ts. Covers:nullwhen the contract isn't configured (no Soroban call made)nullwhen the decoded value isn't a stringnulland logging a warning when the simulation reports an error, or has noretvalnulland logging a warning when the RPC call throwsNote:
new StellarSdk.Contract(id)validates the strkey checksum, so the mocked contract ID in these tests had to be a validly-formatted (though undeployed) contract address, not an arbitrary placeholder string. An earlier draft used a bogus ID and every test silently fell into the catch block instead of exercising the intended code path.#598 - Auth attempt tracker (
src/utils/auth-attempt-tracker.ts)Expanded the existing
tests/unit/utils/auth-attempt-tracker.test.ts(already had good coverage for attempt counting, lockout triggering/escalation, and clearing). Added:ttlof0and the missing-key-2sentinel both report not-locked-outclearAuthFailurestocheckAuthLockoutround-trip, asserting a cleared address is reported as not locked outTest plan
npx vitest runon the 4 touched/added test files: 32/32 passingnpx vitest runon this branch and, in a separategit worktreeoffupstream/main, on a cleannpm cibaseline. Diffed the sorted list ofFAILlines from both runs: identical, 89 pre-existing failing test files in both, confirming these changes introduce zero regressionsnpx eslinton the 4 touched test files: no errors or warningsCaveats
logger.debugissues, a waitlist-serviceundefinedproperty access, a lock TTL mismatch, etc.) are not touched by this PR and were failing identically on a cleanupstream/maincheckout before any of these changes. They're out of scope here.