Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zoe): cache bundles in bundleAndInstall of setUpZoeForTest #10554

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import { Fail } from '@endo/errors';
import { makeIssuerKit } from '@agoric/ertp';
import { AmountMath, makeIssuerKit } from '@agoric/ertp';
import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
import {
deeplyFulfilledObject,
Expand All @@ -15,13 +15,13 @@ import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { makePromiseKit } from '@endo/promise-kit';
import { withAmountUtils } from '../../supports.js';

const trace = makeTracer('BootFAUpg');

export const arV1BundleName = 'assetReserveV1';

const moola = withAmountUtils(makeIssuerKit('moola'));
const moola = makeIssuerKit('moola');
const { make } = AmountMath;

export const buildRootObject = async () => {
const storageKit = makeFakeStorageKit('assetReserveUpgradeTest');
Expand Down Expand Up @@ -226,7 +226,7 @@ export const buildRootObject = async () => {

await E(arLimitedFacet).addIssuer(moola.issuer, 'Moola');

const amt = moola.make(100_000n);
const amt = make(moola.brand, 100_000n);
const collateralSeat = addCollateral(amt);

assert.equal(
Expand Down Expand Up @@ -275,7 +275,7 @@ export const buildRootObject = async () => {
assert.equal(metricsRecord.updateCount, 2n);

// add more collateral
const amt = moola.make(20_000n);
const amt = make(moola.brand, 20_000n);
const collateralSeat = addCollateral(amt);

assert.equal(
Expand Down
8 changes: 6 additions & 2 deletions packages/zoe/tools/setup-zoe.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E, makeLoopback } from '@endo/captp';

import { makeScalarBigMapStore } from '@agoric/vat-data';
import bundleSource from '@endo/bundle-source';
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
import { makeDurableZoeKit } from '../src/zoeService/zoe.js';
import fakeVatAdmin, { makeFakeVatAdmin } from './fakeVatAdmin.js';

Expand Down Expand Up @@ -31,12 +31,14 @@ export const makeZoeForTest = vatAdminSvc =>
* @param {FeeIssuerConfig} [options.feeIssuerConfig]
* @param {VatAdminSvc} [options.vatAdminSvc]
* @param {boolean} [options.useNearRemote]
* @param {string} [options.bundlesDir]
*/
export const setUpZoeForTest = async ({
setJig = () => {},
feeIssuerConfig,
vatAdminSvc,
useNearRemote = false,
bundlesDir = 'bundles',
} = {}) => {
const { makeFar, makeNear } = makeLoopback('zoeTest');

Expand All @@ -56,12 +58,14 @@ export const setUpZoeForTest = async ({
}),
);

const bundleCache = await makeNodeBundleCache(bundlesDir, {}, s => import(s));

/**
* @param {string} path
* @returns {Promise<Installation>}
*/
const bundleAndInstall = async path => {
const bundle = await bundleSource(path);
const bundle = await bundleCache.load(path);
const id = `b1-${path}`;
assert(vatAdminState, 'installBundle called before vatAdminState defined');
vatAdminState.installBundle(id, bundle);
Expand Down
Loading