From c69d6ffb47ece2b8d4a200d52e1637ba57fc3c0e Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Jan 2024 23:03:20 -0600 Subject: [PATCH] test: launcher Larry publishes his asset type --- contract/test/test-arbAssetNames.js | 47 ++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/contract/test/test-arbAssetNames.js b/contract/test/test-arbAssetNames.js index 554a3e6..2cde003 100644 --- a/contract/test/test-arbAssetNames.js +++ b/contract/test/test-arbAssetNames.js @@ -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>>} */ const test = anyTest; @@ -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');