feat: add database state differential testing harness and unit test suite fixes. - #1897
Merged
sublime247 merged 2 commits intoAug 29, 2026
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.
Overview
This PR introduces a Database State Differential Testing Framework to ensure high-fidelity parity between in-memory state representations and live PostgreSQL connections across core domain models (users, vaults, transactions, aml_alerts, and review histories). It also resolves provider test assertion mismatches, adds Ed25519 asymmetric webhook signing, and fixes Jest test runner configuration for ESM packages.
Key Changes
Database Differential Framework
src/utils/mockDb.ts: Added an in-memory database simulation layer supporting SQL INSERT, SELECT, UPDATE queries and constraint validation.
src/utils/dbDifferentialTester.ts: Built a dual-evaluator harness (MockDatabaseStore, RealDatabaseState, DbDifferentialTester) that executes operations concurrently across mock and SQL layers and asserts object equivalence.
Unit & Integration Differential Test Suites
tests/unit/databaseDifferential.test.ts & src/services/tests/dbDifferential.test.ts: Added tests covering:
User creation & KYC lifecycle state transitions (unverified → basic → full).
Vault balance adjustments, status locking, and owner validation.
Transaction lifecycle, metadata/tag serialization, and completion flows.
AML alert generation, rule hit logging, and audit history insertion.
Transaction rollback parity and unique constraint error handling.
Ed25519 Webhook Cryptography
src/crypto/webhookSigning.ts: Added asymmetric outbound webhook signing using Ed25519 keypairs (Stellar secret seeds or standard PEM private keys) with public key derivation and verification.
Provider & Test Configuration Updates
tests/providers/mtn.test.ts: Updated response assertions from strict .toEqual() to .toMatchObject() to accommodate provider structure changes.
jest.config.js:
Excluded Playwright E2E (/tests/e2e/) and Pact tests from the backend Jest runner.
Added transformIgnorePatterns to handle ESM dependencies (e.g. uint8array-extras).
Testing & Verification
Executed unit test suites using Jest:
bash
npx jest tests/unit/ src/services/tests/ tests/providers/ --forceExit
Results: 37 tests passed cleanly across 3 test suites with zero failures.
CLOSES #1834