From 14f700a33a02442bcf72c530b1d96b39060ae99e Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 23 May 2024 11:12:39 -0700 Subject: [PATCH] test: bank balances --- .../test/examples/swapExample.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/orchestration/test/examples/swapExample.test.ts b/packages/orchestration/test/examples/swapExample.test.ts index 86b364bf4412..e4b826f2728e 100644 --- a/packages/orchestration/test/examples/swapExample.test.ts +++ b/packages/orchestration/test/examples/swapExample.test.ts @@ -9,6 +9,7 @@ import { makeHeapZone } from '@agoric/zone'; import { prepareLocalChainTools } from '@agoric/vats/src/localchain.js'; import { buildRootObject as buildBankVatRoot } from '@agoric/vats/src/vat-bank.js'; import { withAmountUtils } from '@agoric/zoe/tools/test-utils.js'; +import { makeFakeBankBridge } from '@agoric/vats/tools/fake-bridge.js'; import { makeFakeLocalchainBridge } from '../supports.js'; const dirname = path.dirname(new URL(import.meta.url).pathname); @@ -26,11 +27,12 @@ test('start', async t => { const zone = makeHeapZone(); const { makeLocalChain } = prepareLocalChainTools(zone.subZone('localchain')); + const bankManager = await buildBankVatRoot( undefined, undefined, zone.mapStore('bankManager'), - ).makeBankManager(); + ).makeBankManager(makeFakeBankBridge(zone)); await E(bankManager).addAsset('uist', 'IST', 'Inter Stable Token', issuerKit); @@ -67,6 +69,14 @@ test('start', async t => { 'Swap for TIA and stake', ); + const bank = await E(bankManager).getBankForAddress( + 'agoric1fakeBridgeAddress', + ); + + const istPurse = await E(bank).getPurse(issuerKit.brand); + // bank purse is empty + t.like(await E(istPurse).getCurrentAmount(), stable.makeEmpty()); + const ten = stable.units(10); const userSeat = await E(zoe).offer( inv, @@ -83,4 +93,7 @@ test('start', async t => { ); const result = await E(userSeat).getOfferResult(); t.is(result, undefined); + + // bank purse now has the 10 IST + t.like(await E(istPurse).getCurrentAmount(), ten); });