-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
packages/orchestration/test/examples/stake-atom.contract.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import { AmountMath } from '@agoric/ertp'; | ||
import { setUpZoeForTest } from '@agoric/zoe/tools/setup-zoe.js'; | ||
import { E } from '@endo/far'; | ||
import path from 'path'; | ||
import type { Installation } from '@agoric/zoe/src/zoeService/utils.js'; | ||
import { commonSetup } from '../supports.js'; | ||
|
||
const dirname = path.dirname(new URL(import.meta.url).pathname); | ||
|
||
const contractFile = `${dirname}/../../src/examples/stakeAtom.contract.js`; | ||
type StartFn = | ||
typeof import('@agoric/orchestration/src/examples/stakeAtom.contract.js').start; | ||
|
||
const coreEval = async ( | ||
t, | ||
{ orchestration, timer, marshaller, storage, bld }, | ||
) => { | ||
t.log('install stakeAtom contract'); | ||
const { zoe, bundleAndInstall } = await setUpZoeForTest(); | ||
const installation: Installation<StartFn> = | ||
await bundleAndInstall(contractFile); | ||
|
||
const { publicFacet } = await E(zoe).startInstance( | ||
installation, | ||
{ In: bld.issuer }, | ||
{ | ||
hostConnectionId: 'connection-1', | ||
controllerConnectionId: 'connection-2', | ||
bondDenom: 'uatom', | ||
}, | ||
{ | ||
marshaller, | ||
orchestration, | ||
storageNode: storage.rootNode, | ||
timer, | ||
}, | ||
); | ||
return { publicFacet, zoe }; | ||
}; | ||
|
||
test('makeAccount, deposit, withdraw', async t => { | ||
const { | ||
bootstrap, | ||
brands: { ist }, | ||
utils, | ||
} = await commonSetup(t); | ||
const { publicFacet } = await coreEval(t, { ...bootstrap, bld: ist }); | ||
|
||
t.log('make an ICA account'); | ||
const account = await E(publicFacet).makeAccount(); | ||
t.truthy(account, 'account is returned'); | ||
const address = await E(account).getAddress(); | ||
// XXX address.address is weird | ||
// t.regex(address.address, /agoric1/); | ||
t.like(address, { chainId: 'FIXME', addressEncoding: 'bech32' }); | ||
|
||
t.log('deposit 100 bld to account'); | ||
await E(account).deposit(await utils.pourPayment(ist.units(100))); | ||
|
||
await t.throwsAsync(E(account).getBalances(), { | ||
message: 'not yet implemented', | ||
}); | ||
}); |