diff options
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); |
