diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-12-02 12:05:24 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-12-02 12:05:24 +0100 |
| commit | 133fcd156d3d11cbdc4ffad1cfca3b814ace48b0 (patch) | |
| tree | b8d22248ab61262d7325c8b6061b6dcc7d3bf0fb /pbt/ts/src/bank.test.ts | |
| parent | 03dd55c022c6077b50429b33f2889bbcec9f0435 (diff) | |
| download | lambda-nantes-133fcd156d3d11cbdc4ffad1cfca3b814ace48b0.tar.gz | |
update bank with model and flow of talk
Diffstat (limited to 'pbt/ts/src/bank.test.ts')
| -rw-r--r-- | pbt/ts/src/bank.test.ts | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/pbt/ts/src/bank.test.ts b/pbt/ts/src/bank.test.ts index 2944e4c..d750d05 100644 --- a/pbt/ts/src/bank.test.ts +++ b/pbt/ts/src/bank.test.ts @@ -1,5 +1,10 @@ import {toNullable} from 'fp-ts/lib/Option'; -import {Account, Operation, SimpleBank} from './bank'; +import { + Account, + Operation, + SimpleBank, + bankImplementationMatchesModel, +} from './bank'; import { Gen, Property, @@ -111,6 +116,32 @@ const correctBalance = }; describe('Bank Simulator', () => { + test('level-db bank conforms to model', async () => { + const prop = forall(genAccounts, async accounts => { + return property(genOperations(accounts), async ops => { + const levelBank = await withTempFile( + filename => new LevelBank(filename), + ).then(bank => bank.populateWith(accounts)); + + return bankImplementationMatchesModel(accounts)(levelBank)(ops); + }); + }); + + const result = await Property.run(prop); + + console.log(result); + console.log(JSON.stringify(result.counterexample)); + + expect(result.result).toBe('OK'); + }); + + // + // + // + // + // + // + test('can retrieve balance given account exists', async () => { const prop = forall(genAccounts, async accounts => { const api = new SimpleBank(accounts); |
