Skip to content

Commit

Permalink
chore(test-launchIt): start with contractStarter
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jan 15, 2024
1 parent e727681 commit 618d7cb
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions contract/test/test-launchIt.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ import { makeFakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import { AmountMath, AssetKind } from '@agoric/ertp/src/amountMath.js';
import { makeIssuerKit } from '@agoric/ertp';
import { creatorCathy, starterSam } from './market-actors.js';
import {
installContractStarter,
startContractStarter,
} from '../src/start-contractStarter.js';

const nodeRequire = createRequire(import.meta.url);

const contractName = 'launchIt';
const bundleRoots = {
[contractName]: nodeRequire.resolve('../src/launchIt.js'),
contractStarter: nodeRequire.resolve('../src/contractStarter.js'),
};

/** @type {import('ava').TestFn<Awaited<ReturnType<makeBundleCacheContext>>>} */
Expand All @@ -39,21 +44,27 @@ const makeWalletFactory = async (powers, issuers) => {
return walletFactory;
};

test.serial('boot walletFactory', async t => {
const { powers, boardAux } = await makeBootstrapPowers(t.log);
test.serial('boot walletFactory, contractStarter', async t => {
const bootKit = await bootAndInstallBundles(t, bundleRoots);
const { powers, bundles } = bootKit;
const walletFactory = await makeWalletFactory(powers, {});
Object.assign(t.context.shared, { powers, walletFactory, boardAux }); // XXX untyped
const bundleID = getBundleId(bundles.contractStarter);

await installContractStarter(powers, {
options: { contractStarter: { bundleID } },
});
await startContractStarter(powers, {});

const starterInstance = await powers.instance.consume.contractStarter;
t.is(typeof starterInstance, 'object');
Object.assign(t.context.shared, { ...bootKit, walletFactory }); // XXX untyped
});

test.serial('start contract', async t => {
const { bundleCache, shared } = t.context;
const { powers, boardAux } = shared;
const { shared } = t.context;
const { powers, boardAux, bundles } = shared;

const bundle = await bundleCache.load(
bundleRoots[contractName],
contractName,
);
const bundleID = getBundleId(bundle);
const bundleID = getBundleId(bundles[contractName]);
const MNY = makeIssuerKit('MNY');

const { walletFactory } = t.context.shared;
Expand All @@ -78,20 +89,19 @@ test.serial('start contract', async t => {
};
const sam = starterSam(
t,
{
wallet: await walletFactory.makeSmartWallet('agoric1sam'),
},
{ wallet: await walletFactory.makeSmartWallet('agoric1sam') },
wellKnown,
);

const { instance } = await E(sam).installAndStart({
bundleID,
issuers: { MNY: MNY.issuer },
issuerKeywordRecord: { MNY: MNY.issuer },
instanceLabel: 'launchIt',
});

t.is(typeof instance, 'object');

Object.assign(t.context.shared, { powers, MNY });
Object.assign(t.context.shared, { powers, MNY, instance });
});

const albert = async (wellKnown, wallet) => {
Expand All @@ -118,7 +128,7 @@ const albert = async (wellKnown, wallet) => {
test.serial('launch a token', async t => {
t.log('Creator Cathy chooses to launch a new token, CDOG, paired with MNY');

const { powers, MNY } = t.context.shared;
const { powers, MNY, walletFactory, instance } = t.context.shared;

powers.brand.produce.MNY.resolve(MNY.brand);
powers.issuer.produce.MNY.resolve(MNY.issuer);
Expand All @@ -132,7 +142,7 @@ test.serial('launch a token', async t => {
assert(await wellKnown.brand.timer, 'no timer brand???');
await creatorCathy(
t,
{ wallet: await walletFactory.makeSmartWallet('agoric1cathy') },
{ wallet: await walletFactory.makeSmartWallet('agoric1cathy'), instance },
wellKnown,
);
t.log('TODO: pool is open for contributions');
Expand Down

0 comments on commit 618d7cb

Please sign in to comment.