Skip to content

Commit

Permalink
test: bank balances
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 23, 2024
1 parent 2eafe0b commit 14f700a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/orchestration/test/examples/swapExample.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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);
});

0 comments on commit 14f700a

Please sign in to comment.