Skip to content

Commit

Permalink
test: launcher Larry publishes his asset type
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jan 21, 2024
1 parent 77ed3d5 commit fe0d2cf
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions contract/test/test-arbAssetNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import { test as anyTest } from './prepare-test-env-ava.js';
import { createRequire } from 'module';

import { E } from '@endo/far';
import {
bootAndInstallBundles,
getBundleId,
makeBundleCacheContext,
} from './boot-tools.js';
import { startArbAssetName } from '../src/start-arbAssetName.js';
import { mockWalletFactory } from './wallet-tools.js';
import { launcherLarry } from './market-actors.js';
import { makeStableFaucet } from './mintStable.js';

/** @type {import('ava').TestFn<Awaited<ReturnType<makeBundleCacheContext>>>} */
const test = anyTest;
Expand All @@ -23,19 +27,46 @@ const bundleRoots = {
[contractName]: nodeRequire.resolve('../src/arbAssetNames.js'),
};

test('Start arbitrary asset naming contract', async t => {
test('launcher Larry publishes his asset type', async t => {
const { powers, bundles } = await bootAndInstallBundles(t, bundleRoots);

await startArbAssetName(powers, {
assetNamingOptions: {
bundleID: getBundleId(bundles[contractName]),
price: 100n,
unit: 1_000_000n,
},
});
const config = {
bundleID: getBundleId(bundles[contractName]),
price: 100n,
unit: 1_000_000n,
};
await startArbAssetName(powers, { assetNamingOptions: config });
const instance = await powers.instance.consume.arbAssetName;
t.log(instance);
t.is(typeof instance, 'object');

const { agoricNames, zoe, namesByAddressAdmin, chainStorage, feeMintAccess } =
powers.consume;
const { price } = await E(zoe).getTerms(instance);
const wellKnown = {
installation: {},
instance: powers.instance.consume,
issuer: powers.issuer.consume,
brand: powers.brand.consume,
terms: { arbAssetName: { price } },
};

const walletFactory = mockWalletFactory(
{ zoe, namesByAddressAdmin, chainStorage },
{
Invitation: await wellKnown.issuer.Invitation,
IST: await wellKnown.issuer.IST,
},
);
const { bundleCache } = t.context;
const { faucet } = makeStableFaucet({ feeMintAccess, zoe, bundleCache });
const funds = await E(faucet)(price.value * 2n);
const wallet = await walletFactory.makeSmartWallet('agoric1launcherLarry');
await E(wallet.deposit).receive(funds.withdraw(funds.getCurrentAmount()));
const info = await launcherLarry(t, { wallet }, wellKnown);
const publishedBrand = await E(agoricNames).lookup('brand', info.id);
t.log(info.brand, 'at', info.id);
t.is(publishedBrand, info.brand);
});

test.todo('publish an issuer / brand');
Expand Down

0 comments on commit fe0d2cf

Please sign in to comment.