Repository navigation
test(ngn): prove the idempotency claims, and correct the ones that do not hold (W090) - #249
Conversation
… not hold (W090) Adds a fake Linq provider that records each provider assumption as a labelled BELIEF, plus client-level and route-level suites covering a duplicate request and three kinds of dropped response. Corrects comments that overclaimed: onramp and bill creation are retried without an idempotency key, provisionCustomer is keyed on customerRef alone, and the webhook is idempotent per event but not order-safe. docs/idempotency.md records each route's guarantee and the key's scope and lifetime. Closes Miracle656#247 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Glorious21 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! 🚀 |
Keeps both doc comments on provisionCustomer: the reused-reference note from main and the caveats about what idempotent provisioning does not promise.
|
Merged. The finding is worth more than the tests, and the tests are good.
Three different guarantees behind one
True for the offramp, false for onramp orders and bills. That is precisely the sentence that would let the next person wrap a fourth unkeyed call in the same helper on the grounds that it is safe. A comment that is confidently wrong about money is worse than no comment, and finding it is the kind of thing only writing the tests would have surfaced. Two resolutions while merging
expect([a.status, b.status].sort()).toEqual([201, 500]);pinned as a known edge, which was correct when you wrote it. #210 closed that edge earlier today: the route catches the unique violation, reads the winning row back and answers it through the same replay path a sequential duplicate takes, so the loser now gets 200 and the order. I updated the assertion and the test name and left the history in the comment. I want to be clear that this is your suite working, not failing. It noticed a deliberate behaviour change on the day it landed, which is the entire point of pinning behaviour — and it is a much better outcome than the test having been written loosely enough not to notice. Verified on the merge result rather than your branch: Closes #190. |
Summary
Proves (or corrects) every idempotency claim on the naira rails.
src/__tests__/fakes/linqProvider.ts): replacesglobal.fetchwith no way through to the network; each provider assumption is markedBELIEF:. W089's fake doesn't exist yet, so this one is kept small for W089 to extend. No KYC endpoint, so it never sees a NIN.linq/idempotency.test.ts(client functions) androutes/idempotency.test.ts(HTTP routes, with an in-memory DB that enforces the schema's unique indexes). They cover a plain duplicate and three kinds of dropped response: the client never got our answer; Linq's answer never reached us; Linq created the order but our DB write failed.docs/idempotency.md: per-route guarantees, the key's scope and lifetime, and what is proven versus believed.Claims corrected
retryOnProviderFailuresaid every retry carries an idempotencyKey. Onramp and bills send none, so a retry after a lost answer creates a second (unpaid) order. Now documented and pinned in tests; behaviour unchanged.provisionCustomer: keyed oncustomerRefalone, so a repeat with new details keeps the old ones, andcreatedcan befalsefor a customer the same call created.recordNgnOrder: "a double-submit updates the row" was wrong. A double-submit is two orders.For W079
Before retrying KYC, ask Linq what a second submission of the same NIN for the same
customerRefreturns. If it isnin_already_used, a retry after a dropped response turns a success into a refusal.Related issue
Closes #247
Type of change
Checklist
npx tsc --noEmitpassesnpm run buildpassesnpm test: 719 passed, 2 failed, both inopenapiCoverage(W082, red onmainalready). Checked that the tests aren't empty: switching off the fake's offramp dedupe fails 6, and bypassing the route's own key check fails 2.🤖 Generated with Claude Code