diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-12-01 17:16:38 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-12-01 17:16:38 +0100 |
| commit | 01660b4c6ac5d451102d73a7df22483f9fcc2ea1 (patch) | |
| tree | e4684d483e235c06c1a65956b2b87c3e69d63406 /pbt/ts/src/bank.test.ts | |
| parent | f8f9f6d77ad589dcbdf2749cade4cadc827c805f (diff) | |
| download | lambda-nantes-01660b4c6ac5d451102d73a7df22483f9fcc2ea1.tar.gz | |
complete operations sequence tests
Diffstat (limited to 'pbt/ts/src/bank.test.ts')
| -rw-r--r-- | pbt/ts/src/bank.test.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pbt/ts/src/bank.test.ts b/pbt/ts/src/bank.test.ts index c448242..bbb6fcf 100644 --- a/pbt/ts/src/bank.test.ts +++ b/pbt/ts/src/bank.test.ts @@ -60,9 +60,10 @@ const genOperations = (accounts: Map<Account, number>) => listOf(genOneOperation(accounts)); const correctBalance = - (api: SimpleBank, initialAccounts: Map<Account, number>) => + (initialAccounts: Map<Account, number>) => (ops: Operation[]): boolean => { const expectedBalances = new Map(initialAccounts); + const api = new SimpleBank(initialAccounts); for (const op of ops) { switch (op.op) { @@ -70,6 +71,9 @@ const correctBalance = const retrieved = toNullable(api.balance(op.account)); const expected = expectedBalances.get(op.account); if (retrieved !== expected) { + console.log( + `Balance mismatch for account ${op.account}: expected ${expected}, got ${retrieved}`, + ); return false; } break; @@ -93,6 +97,9 @@ const correctBalance = for (const [account, expectedBal] of expectedBalances.entries()) { const retrieved = toNullable(api.balance(account)); if (retrieved !== expectedBal) { + console.log( + `Final balance mismatch for account ${account}: expected ${expectedBal}, got ${retrieved}`, + ); return false; } } @@ -116,16 +123,12 @@ describe('Bank Simulator', () => { }); test('correctly update balance given a sequence of deposits and withdrawals', () => { - const genTransactionAmount: Gen<number> = choose(1, 100000); - const prop = forall(genAccounts, accounts => { - const api = new SimpleBank(accounts); - return property(genOperations(accounts), correctBalance(api, accounts)); + return property(genOperations(accounts), correctBalance(accounts)); }); const result = Property.run(prop); - console.log(result); expect(result.result).toBe('OK'); }); }); |
