Repository navigation
test(testing): boot each kyc e2e app on its own database - #341
Closed
mp-blurify wants to merge 1 commit into
Closed
mp-blurify wants to merge 1 commit into
mp-blurify wants to merge 1 commit into
Conversation
The re-kyc-on-deposit test failed about one run in three since at-least-once delivery. Its two apps shared one database, and every booted app runs an outbox relay over that database that publishes into its own Redis. When the stock app's relay claimed the deposit event the gated app wrote, the stock app's compliance handler, which has no re-kyc thresholds, handled it and the gated app never saw it. Each app now gets its own test database, seeded right after it boots. The bootTestApp doc no longer claims apps cannot compete for each other's events. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Mateusz Paś <mateusz.pas@studiosoftware.com>
mp-blurify
requested review from
jakubfilinger-b,
klaudia-blazyczek-blurify,
marek-chmielowski-blurify,
okapitula and
zaxovaiko
as code owners
October 21, 2026 12:05
zaxovaiko
approved these changes
Oct 21, 2026
Collaborator
Author
|
Superseded by #312: |
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
kyc.e2e.test.ts> "a deposit crossing the per-currency threshold flips a legacy-verified player to resubmission_requested" failed about one run in three since at-least-once event delivery (#297). The suite's two apps now each run on their own database, so the deposit event always reaches the app that has the re-KYC thresholds.Why
The suite boots two apps on one database, each with its own Redis logical database:
appDefault: the stock stack.appGated: adds an overlay that bindskyc.reverifyThresholds.Since #297, wallet and KYC events go through
event_outbox. Every booted app runs anOutboxRelayover its database and publishes into its own broker, so the two relays race for each row. SometimesappDefault's relay claimed thewallet.deposit.completedthatappGatedwrote and published it intoappDefault's Redis.appDefault's compliance handler then ranhandleDepositwith no thresholds and did nothing.appGatednever received the event, and the basic KYC row stayedpending.Measured over 16 runs of the test, with each app's
MESSAGE_BROKER.publishwrapped to record which app published the event (diagnostic only, not committed):appGatedappDefaultverifiedstatus was intact and everywallet.deposit.completedhandler had recorded the event inprocessed_eventsThe problem is which app gets the event, not latency, so a longer
waitForwould not help.Each app now gets its own
setupTestDb()and is seeded right after it boots. This order matters becauseseedMinimalreads theDATABASE_URLset by the most recently booted app;qa-wallet-auto-withdrawal-configalready works this way. No test in the file uses data across the two apps.bootTestApp's doc said apps in one file cannot compete for each other's events. It now says they do when they share a database.Locally the file passed 20 runs in a row after the change. Before it, 10 of 34 runs failed.
Alternatives considered
waitFortimeout. The event is in the other app's Redis, so no wait reaches it.processed_eventskeys handlers bySERVICE_NAME, which ismonolith/...for every test app, so whichever app handled the event first would mark it done for the other. Apps with different overlays would also share BullMQ queues.bootTestAppguard that refuses a second app on a database already in use.wallet-ledger-auto-withdrawal,gaming-category-rulesandgaming-category-sortshare a database between apps but are not affected. What they wait on is either handled the same way by every app (audit rows, notifications, the process-wide email capture) or sent withemit(), which publishes to the emitting app's own broker without going through the outbox. So they stay as they are.Risks
None. This is a test-only change. In production, replicas share one Redis, so whichever relay publishes an event, every service's consumer group receives it.