Testing money and regulated systems
When software moves money, the test that matters runs every day in production and compares two records that should agree. Your job is to design that comparison, prove it can find a break, and keep evidence an auditor can check
Your daily reconciliation between the ledger and the bank statement reports a net difference of £0.00. What does that tell you?
Testing systems that move money is different from testing a feature, for two reasons. The first is that the most important bugs are not visible to the user who triggered them. A double posting, a rounding drift, a refund that credits the wrong currency: each looks fine on the screen and is wrong in the books, and someone finds it weeks later, or never. The second is that someone outside engineering, a finance controller, an internal auditor, an external auditor, a card-scheme assessor or a regulator, will ask you to prove what you tested, and “the pipeline was green” is not an answer they can accept.
At lead level you own both problems across several teams. You do not write every test. You design the controls that catch money errors in production, make sure each one has been proven to work, and make sure the evidence of every run survives long enough to be inspected. This chapter covers the model, the arithmetic that causes most money bugs, the reconciliation test plan, audit evidence, and the regular work. It assumes the payment ledger lesson for double entry and the idempotency lesson for retries; the idempotency-key tests themselves live in API, contract and integration testing.
The model: two records that must agree
Every system that moves money keeps at least two records of the same money, and they are kept by different parties. Your ledger says what you think happened. The bank statement, the card scheme’s clearing and settlement files, the payment processor’s reports, and the general ledger in the finance system each say what someone else thinks happened. A reconciliation is a scheduled comparison of two such records, item by item, that reports every difference, called a break, for someone to explain and resolve.
Reconciliation is the most important test in a money system, for a reason that has nothing to do with QA tradition. Pre-release tests check the code against your understanding of the world. Reconciliation checks your records against the world. The bank does not care what your test fixtures said a refund file looks like. When the processor changes a field, when a scheme sends a late presentment, when an engineer runs a manual data fix, only reconciliation sees it.
There are three kinds, and a money system needs all three:
| Kind | Compares | Catches | Example |
|---|---|---|---|
| Internal | Two of your own records | Bugs in your code and data fixes | Sum of customer balances against the ledger control account |
| External | Your record against a third party’s | Missing, duplicated or mismatched movements | Ledger postings against the scheme clearing file |
| Cash | Expected movement against the bank statement | Money that should have moved and did not | Net settlement position against the settlement account |
Stripe’s engineering write-up of its Ledger system, in the reading, describes the internal kind well: money passes through clearing accounts that should return to zero once a flow completes, so “find the clearing accounts with a non-zero balance” becomes a query that finds missing, late or incorrect events. The same post separates completeness (every event in a producer system arrived in the ledger) and timeliness (it arrived within a known window) from correctness. Those three words are a useful checklist for any reconciliation you design.
The lead’s model, then: pre-release testing reduces the number of breaks; reconciliation detects the ones that get through; evidence proves both happened. A money system with excellent pre-release tests and no reconciliation is a system that cannot tell when it is wrong.
The arithmetic that breaks
Most money bugs are not exotic. They are arithmetic, and the same five appear in every codebase.
Floating point. Binary floating point cannot represent 0.1 exactly, so 0.1 + 0.2 is not 0.3. Store amounts as integers in minor units (pence, cents) or as a decimal type with fixed scale, never as a float. A test that sums a thousand small amounts and compares against the expected total catches this in seconds.
Currency exponents. ISO 4217 gives each currency a minor-unit exponent: 2 for GBP, EUR and USD, 0 for JPY, 3 for KWD and BHD. Code that assumes two decimal places turns ¥1,500, stored as 1500 with exponent 0, into ¥15.00, a hundredfold error, and turns 1.500 KWD into 15.00. Every currency path needs tests in at least one zero-exponent and one three-exponent currency. The API chapter’s opening story, pounds sent where the ledger expected pence, is the same bug in its commonest form.
Rounding rules. Half-up and half-even (banker’s rounding) differ on exact halves, and the processor, the scheme and your code may each use a different one. Write down which rule each system uses and test the halves explicitly: 2.345 to two places is 2.35 half-up and 2.34 half-even.
Allocation remainders. Split £10.00 three ways and you get £3.33 three times, which is £9.99. A penny has vanished. The fix is an allocation rule, the remainder goes to the first or the largest share, and the test asserts that the parts always sum to the whole. Property-based tests are well suited here: generate thousands of random amounts and splits and assert the sum invariant each time.
FX conversion order. A $19.99 purchase converted at 0.7863 is £15.718137, which rounds to £15.72. Convert each of a thousand such transactions and round each, and you get a different total from summing first and converting once. Neither is wrong; they are different rules, and the scheme, the processor and your ledger must agree on which. Store the rate, its source and timestamp, the original amount and currency, and the converted amount on every converted posting, so a reconciliation can recompute it.
None of these needs a lesson on how to fix it. Each needs a test that asserts the invariant: amounts are integers with a currency; parts sum to the whole; a conversion can be recomputed from what was stored. The payment ledger lesson gives the deepest invariant of all, that every journal entry sums to zero, and that one belongs in a test that runs against every build and a check that runs against production every day.
Designing a reconciliation
A reconciliation is a test with a definition, and the definition is what an auditor will read first. It has six parts.
What is reconciled. One population, precisely: “all clearing records in GBP and EUR received from the scheme for business date D”, not “card transactions”.
Against what. The independent source, and why it is independent. A reconciliation of your ledger against a report generated from your ledger is a tautology.
The match key. What makes two items the same item. For card clearing, a scheme reference such as the acquirer reference number, plus amount and currency. For a bank statement, your end-to-end payment reference. Weak keys produce false matches, which are worse than breaks, because a false match is a break nobody sees. Test the key: two different transactions with the same amount on the same day must not match each other.
Tolerance. How large a difference is accepted without a break. Practitioners disagree here. One school holds that internal reconciliations must have zero tolerance, because every difference is a bug and a tolerance is a place for bugs to hide. The other holds that external reconciliations involving FX or third-party rounding need a small per-item tolerance, or the team drowns in breaks of a penny and stops reading them. A workable middle: zero tolerance on counts and on any reconciliation within one currency; a per-item tolerance only where a documented rounding or FX rule causes it; and an aggregate cap, so a thousand one-penny differences still raise a break. Whatever you choose, write down the reason, because the auditor will ask.
Cadence and timing. How often it runs, and how long an item may stay unmatched before it becomes a break. Schemes and banks deliver late; a clearing record may legitimately arrive two days after the authorisation. Define the window, and age breaks from the end of it.
Evidence and sign-off. What is kept from each run, where, for how long, and who reviews it. This is the part most teams leave out, and the next section is about it.
Then test the reconciliation itself. A reconciliation that has never reported a break is not proof that the system is clean. It may be proof that the reconciliation cannot see. Before a reconciliation goes live, and after any change to it, run it against data seeded with known breaks: a missing item, a duplicate, an amount off by one minor unit, a wrong currency exponent, an item outside the timing window, two items that share an amount and nothing else. Each seeded break must appear in the report, classified correctly. This is mutation testing applied to a control, and it is the single most valuable thing a QA lead brings to a finance or operations team that already runs reconciliations.
Audit evidence
An auditor testing a control asks two questions. Is the control designed to catch the risk? Did it operate, every time it was supposed to, over the period? The second is where engineering teams fail, because the evidence was never kept or was kept somewhere it could be changed.
Audit frameworks name this: in a SOC 1 or SOC 2 Type II report the auditor tests the operating effectiveness of controls over a period, and in a Sarbanes-Oxley audit, IT general controls (change management, access, operations) cover the systems that produce financial figures. In both, the auditor picks a sample of dates or changes and asks you to show that the control ran on each and that someone reviewed it. Sample sizes depend on the auditor’s methodology; ask for theirs rather than guessing.
Evidence that survives this has five properties:
- Created when the control ran, by the system that ran it, not assembled afterwards. A screenshot taken the week the auditor asked is not evidence.
- Complete: the time, the code or configuration version (a commit hash), identifiers and hashes of the inputs (a SHA-256 of each file), counts on both sides, the breaks found, and the result.
- Immutable: written to storage nobody on the team can edit or delete during the retention period, such as object storage with a write-once lock.
- Reviewed: a named person, not the one who wrote the code, signed off the result and the handling of each break, and that sign-off is recorded with a time.
- Retained for the period finance and legal set, which is usually years, not the 90 days your CI system keeps logs by default.
Card data adds specific rules. PCI DSS v4.0.1, from the PCI Security Standards Council, requires in Requirement 6.5.5 that live primary account numbers are not used in pre-production environments (unless those environments are in scope and protected as production), and in 6.5.6 that test data and test accounts are removed before a system goes into production. Requirement 10.5.1 asks for audit log history to be retained for at least twelve months, with the most recent three months immediately available. Requirement 11 covers security testing, which is the security team’s, not yours. Read the standard itself from the PCI SSC document library rather than a vendor summary, and confirm with your assessor which systems are in scope.
The three lines of defence model, common in banks, explains who signs what. The first line (engineering and operations) runs the control and reviews breaks. The second line (risk and compliance) sets the standard and checks the first line follows it. The third line (internal audit) tests independently. As QA lead you sit in the first line. You do not sign off your own team’s control as independent assurance, and you should not want to.
Where practitioners disagree
Pre-release testing or production detection. Some leads put most of their effort into pre-release suites: replay a day of production files through the new build, diff the ledger output against the current build, and block the release on any difference. Others argue that the world changes faster than fixtures, and the effort is better spent on reconciliations that run every day. The answer for money is both, but if you must choose where the next month goes, the reconciliation with the most money and the least evidence usually wins.
Who owns reconciliation. In many companies finance operations owns reconciliation, engineering owns the ledger, and nobody owns the code that compares them. QA is well placed to own the test of the reconciliation and the evidence design, without owning the break resolution, which belongs with the people who can move money to fix it.
Production test transactions. Some teams run small real transactions in production, on cards and accounts the company owns, to prove the full path end to end each day. Others forbid it because test accounts in production are exactly what PCI DSS 6.5.6 and many auditors look for. If you do it, get compliance to approve it in writing, use real accounts the company owns rather than test accounts, and reconcile those transactions like any other.
Day to day
Daily, fifteen to thirty minutes. Read the break report from each reconciliation. You are not resolving breaks; operations does that. You are looking for patterns that mean a bug: a new kind of break, a break rate that changed after a release, a reconciliation that reported zero breaks on a day it normally reports a few, which can mean it read an empty file. A run that did not happen is itself a break.
Weekly, one meeting. A break review with finance operations and the engineering leads for the money services, thirty to forty-five minutes. Ageing breaks by reconciliation, root causes for the week’s new kinds, and which ones need a code fix. Bring the gross value of open breaks, not the net.
Per release touching a money path. A parallel run: replay one or more days of masked production inputs through the new build and the current one and diff the ledger postings. Every difference is either intended (listed in the change) or a defect. Record the run as evidence, with the hashes and versions, and link it from the release record in the format described in release management and sign-off.
Per change to a reconciliation. Rerun the seeded-break suite. A reconciliation change without that evidence does not ship.
Monthly. Month-end close: finance needs every reconciliation complete and signed before the books close. Expect questions on any break older than its window, and make sure the evidence for the month is complete before someone asks.
Quarterly and annually. Internal audit tests a sample; the external auditor tests the IT general controls; for card businesses, a Qualified Security Assessor reviews PCI DSS compliance, in a programme the security lead usually runs (the security track’s compliance and audits chapter covers it). Your job in these is to hand over evidence that already exists, in the form the auditor’s request list asks for, within the days they give you. If preparing evidence takes you weeks, the evidence design is wrong; fix it after the audit, not during.
Coaching, throughout. You teach QA engineers on each team to add the five arithmetic tests to every money-path change, to think in invariants, and to write a reconciliation definition before a new money flow ships. Linking each new flow to an owned reconciliation is a reasonable exit criterion in any test strategy for a money feature.
There is no QA team and probably no finance operations team: a founder or an early finance hire reconciles in a spreadsheet against the bank statement each week. Your contribution, as whichever engineer cares most, is one automated daily reconciliation between the ledger and the bank or processor, item by item, with breaks posted to a channel, and the invariant tests in CI: integer minor units, parts sum to the whole, entries sum to zero. Keep the run output in storage nobody deletes. The first audit, often at a funding round or a banking partner’s due diligence, will ask for it.
A finance operations team exists and owns reconciliations, often in a mix of SQL, spreadsheets and a vendor tool. Engineering ships money changes weekly. The gap is between them: changes that break reconciliations nobody in engineering knew existed. The QA lead builds the inventory of reconciliations with owners, adds seeded-break tests, puts a parallel run in the release path for money services, and designs the evidence format before the first SOC 1 or PCI assessment rather than during it. Expect to negotiate tolerances with finance and to win some.
Reconciliations number in the hundreds, live in a dedicated platform, and are formal controls in a risk register with second-line oversight. The problem is change: a new product or scheme mandate touches twenty reconciliations owned by six teams, and the control descriptions the auditors test lag behind the code. The QA lead’s work is coverage and evidence at scale: mapping money flows to controls, making the evidence of every run machine-generated and immutable, and representing engineering in audit planning so requests arrive as queries, not as weeks of screenshots.
Template
# Reconciliation test plan: <money flow or product>
Owner (QA) · Control owner (finance/ops) · Reviewer · Version · Date
## Scope
Money flows covered: <list>. Out of scope: <list, with reason>.
Currencies and their ISO 4217 exponents: <GBP 2, JPY 0, ...>
## Reconciliations
| ID | What (population) | Against (independent source) | Match key | Tolerance and reason | Cadence | Window before break |
|---|---|---|---|---|---|---|
| R1 | | | | | | |
## Invariant tests (every build)
- Amounts are integer minor units with a currency
- Allocations sum to the whole
- Every journal entry sums to zero
- FX postings store rate, source, time, original and converted amounts; recomputation matches
## Proving each reconciliation (seeded breaks)
| Break seeded | Expected report | Last run | Result |
|---|---|---|---|
| Missing item | | | |
| Duplicate | | | |
| Amount off by one minor unit | | | |
| Wrong currency exponent | | | |
| Item outside window | | | |
| Same amount, different item (false match) | | | |
## Release gate (changes to money paths)
Parallel run: <days of masked input>, diff of postings, how differences are classified.
## Evidence retained per run
Fields: <time, code version, input hashes, counts both sides, breaks, result, reviewer, sign-off time>
Store: <immutable location> · Retention: <period, set by whom> · Card data: <how PANs are masked or tokenised>
## Who signs
Run reviewed by: <role> · Breaks resolved by: <role> · Independent check: <second/third line>
## Alerts
A missed run, an empty input file, or a break rate outside <range> pages: <who> WORKED EXAMPLE
Merganser is a fictional card issuer with 1.2 million debit cards in the UK and Ireland, about 380,000 clearing records a day, and a QA lead covering four teams. Their plan for card clearing and settlement, adopted in the autumn after the March evidence gap in the decision below, abridged.
Currencies. Cardholder accounts in GBP and EUR (exponent 2). Transactions arrive in any currency, including JPY (0) and KWD (3); the scheme converts to the billing currency.
R1, clearing to ledger. Every clearing record in the scheme’s daily file for business date D against ledger postings. Key: acquirer reference number plus billing amount and currency. Tolerance zero: the scheme has already converted, so Merganser posts the billing amount it is given. Window: T+3 for late presentments.
R2, settlement to cash. The scheme’s net settlement figure for D against the movement on the settlement bank account. Tolerance zero. Daily.
R3, customer balances to control account. Sum of all cardholder balances against the general ledger control account, internal, zero tolerance, hourly.
Seeded breaks. Run on every change to the reconciliation code and monthly regardless. Last month’s run caught that R1 treated a KWD original amount of 12.500 as 125.00 in its exception report; the match itself was correct because it keys on billing amount, but the report misled operations. Fixed before release.
Release gate. Two days of masked clearing files (PANs replaced by tokens, per PCI DSS 6.5.5) replayed through both builds; 761,204 postings diffed; zero unexplained differences required.
Evidence. Each run writes a JSON record with time, commit, SHA-256 of each input file, counts, breaks and the reviewer’s sign-off to write-once storage. Retention: seven years, set by the finance director. Daily review by finance operations; QA lead reviews the weekly trend; internal audit samples quarterly.
Now you
You are the new QA lead at Dunlin Wallet, a fictional mobile-money wallet with 900,000 users. Customers top up by bank transfer and card, send money to each other, and cash out to bank accounts. As an e-money issuer, Dunlin must hold customer funds in a safeguarding account that at least matches the total of customer balances. Finance runs one reconciliation, weekly, in a spreadsheet: the safeguarding bank balance against a ledger export, net. Last quarter a top-up retry bug credited 312 wallets twice before support noticed; the weekly net figure had looked fine, because cash-outs had moved the other way. The external auditor arrives in ten weeks and will ask for evidence of safeguarding reconciliations for the year. Engineering keeps CI logs for 30 days. Write the reconciliation test plan for top-up, transfer and cash-out, including what you can and cannot evidence for the period already past.
Self-check
Merganser's external auditor is testing change management. From a sample of 25 releases, they pick one from March that changed clearing logic and ask for proof that the parallel-run test ran before it shipped. The release ticket says 'parallel run passed' with a QA engineer's name. The CI logs from March were deleted after 90 days. The auditor needs an answer by Friday. What do you give them?
- POST Ledger: Stripe's system for tracking and validating money movement Ilya Ganelin, 2024
Clearing accounts that should return to zero, and data-quality checks split into clearing, completeness and timeliness. The clearest public description of reconciliation built into a ledger at scale.
- POST Books, an immutable double-entry accounting database service Łukasz Strzałkowski, 2019
Why Square replaced a settlement system that produced inconsistent data with an append-only double-entry store. Read it for the invariants worth testing: entries balance, records are never mutated, corrections are new entries.
- POST Accounting for Developers, Part I Modern Treasury, 2022
Debits, credits, normal balances and why balances are derived from transactions. Enough accounting to read a finance team's reconciliation and argue about it as an equal.
- DOC PCI Security Standards Council document library PCI Security Standards Council
The primary source for PCI DSS v4.0.1. Read Requirement 6.5 on test data and pre-production environments and 10.5 on log retention yourself rather than through a vendor summary.
- DOC Bates and others v Post Office Ltd (No 6: Horizon Issues) [2019] EWHC 3408 (QB) Mr Justice Fraser, High Court, 2019
A court's examination of what happens when a financial system's figures are trusted over the people using it. Read the answers to the Horizon Issues near the end, especially on robustness and on the records that were not kept.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.