From 58d1501214a3dd1d44e6824f8179c8324a88a367 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 6 Apr 2023 21:35:50 -0600 Subject: [PATCH 1/4] fix(solo): minor tweaks to `ag-solo`s CapTP service --- packages/solo/src/captp.js | 6 +++--- packages/solo/src/web.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/solo/src/captp.js b/packages/solo/src/captp.js index 7c964b011a3..bc8dbc078ed 100644 --- a/packages/solo/src/captp.js +++ b/packages/solo/src/captp.js @@ -3,11 +3,11 @@ import { E, makeCapTP } from '@endo/captp'; import { Far } from '@endo/marshal'; export const getCapTPHandler = (send, getLocalBootstrap, fallback) => { - let lastEpoch; + let lastEpoch = 0; const chans = new Map(); const doFallback = async (method, ...args) => { if (!fallback) { - return harden({}); + return false; } return E(fallback)[method](...args); }; @@ -74,7 +74,7 @@ export const getCapTPHandler = (send, getLocalBootstrap, fallback) => { } const done = await doFallback('onMessage', obj, meta); if (!done) { - console.error(`Could not find handler ${obj.type}`, meta); + console.error(`Could not find handler ${obj.type}`, obj, meta); } return done; }, diff --git a/packages/solo/src/web.js b/packages/solo/src/web.js index 899a5adf0e7..25547a6b550 100644 --- a/packages/solo/src/web.js +++ b/packages/solo/src/web.js @@ -356,6 +356,9 @@ export async function makeHTTPListener( try { obj = JSON.parse(message); const res = await inboundCommand(obj, meta, id); + if (typeof res === 'boolean') { + return; + } // eslint-disable-next-line no-use-before-define sendJSON({ ...res, meta }); @@ -371,9 +374,7 @@ export async function makeHTTPListener( wss.on('connection', newChannel); function sendJSON(rawObj) { - const { meta: { channelID } = {} } = rawObj; - const obj = { ...rawObj }; - delete obj.meta; + const { meta: { channelID } = {}, ...obj } = rawObj; // Point-to-point. const c = channels.get(channelID); From 34a3af54e91195e26d3967edf4920e67f16e9b52 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Tue, 11 Apr 2023 21:03:01 -0600 Subject: [PATCH 2/4] test(inter-protocol): rebuild `test/smartWallet` bundles on demand --- .../test/smartWallet/contexts.js | 27 ++++++++++++++++--- .../smartWallet/test-oracle-integration.js | 12 +++++---- .../test/smartWallet/test-psm-integration.js | 11 ++++---- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/packages/inter-protocol/test/smartWallet/contexts.js b/packages/inter-protocol/test/smartWallet/contexts.js index 7476b58d9aa..2ceef66844b 100644 --- a/packages/inter-protocol/test/smartWallet/contexts.js +++ b/packages/inter-protocol/test/smartWallet/contexts.js @@ -1,6 +1,5 @@ import { BridgeId, deeplyFulfilledObject } from '@agoric/internal'; import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; -// eslint-disable-next-line no-unused-vars -- used by TS import { coalesceUpdates } from '@agoric/smart-wallet/src/utils.js'; import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js'; import { E } from '@endo/far'; @@ -8,21 +7,41 @@ import path from 'path'; import { createPriceFeed } from '../../src/proposals/price-feed-proposal.js'; import { withAmountUtils } from '../supports.js'; +// referenced by TS +coalesceUpdates; + +const bundlesToCache = harden({ + psm: './src/psm/psm.js', + econCommitteeCharter: './src/econCommitteeCharter.js', +}); + +export const importBootTestUtils = async (log, bundleCache) => { + // Preload the cache entries needed by boot-test-utils.js. + await Promise.all( + Object.entries(bundlesToCache).map(async ([name, entrypoint]) => + bundleCache.validateOrAdd(entrypoint, name), + ), + ); + return import('@agoric/vats/tools/boot-test-utils.js'); +}; + /** * @param {import('ava').ExecutionContext} t - * @param {(logger) => Promise} makeSpace + * @param {(logger, cache) => Promise} makeSpace */ export const makeDefaultTestContext = async (t, makeSpace) => { // To debug, pass t.log instead of null logger const log = () => null; - const { consume, produce } = await makeSpace(log); + + const bundleCache = await unsafeMakeBundleCache('bundles/'); + + const { consume, produce } = await makeSpace(log, bundleCache); const { agoricNames, zoe } = consume; //#region Installs const pathname = new URL(import.meta.url).pathname; const dirname = path.dirname(pathname); - const bundleCache = await unsafeMakeBundleCache('bundles/'); const bundle = await bundleCache.load( `${dirname}/../../../smart-wallet/src/walletFactory.js`, 'walletFactory', diff --git a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js index 31bddbbab9d..7155d2b35a4 100644 --- a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js @@ -4,10 +4,6 @@ import { NonNullish } from '@agoric/assert'; import { coalesceUpdates } from '@agoric/smart-wallet/src/utils.js'; import { buildRootObject } from '@agoric/vats/src/core/boot-psm.js'; import '@agoric/vats/src/core/types.js'; -import { - mockDProxy, - mockPsmBootstrapArgs, -} from '@agoric/vats/tools/boot-test-utils.js'; import { eventLoopIteration } from '@agoric/zoe/tools/eventLoopIteration.js'; import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { E } from '@endo/far'; @@ -18,6 +14,7 @@ import { ensureOracleBrands } from '../../src/proposals/price-feed-proposal.js'; import { headValue } from '../supports.js'; import { currentPurseBalance, + importBootTestUtils, makeDefaultTestContext, voteForOpenQuestion, } from './contexts.js'; @@ -31,7 +28,12 @@ const test = anyTest; const committeeAddress = 'econCommitteeMemberA'; -const makeTestSpace = async log => { +const makeTestSpace = async (log, bundleCache) => { + const { mockDProxy, mockPsmBootstrapArgs } = await importBootTestUtils( + log, + bundleCache, + ); + const psmParams = { anchorAssets: [{ denom: 'ibc/toyusdc', keyword: 'AUSD' }], economicCommitteeAddresses: { diff --git a/packages/inter-protocol/test/smartWallet/test-psm-integration.js b/packages/inter-protocol/test/smartWallet/test-psm-integration.js index 9c663d32f1c..a270ea39c63 100644 --- a/packages/inter-protocol/test/smartWallet/test-psm-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-psm-integration.js @@ -4,10 +4,6 @@ import { AmountMath, makeIssuerKit } from '@agoric/ertp'; import { buildRootObject as buildPSMRootObject } from '@agoric/vats/src/core/boot-psm.js'; import '@agoric/vats/src/core/types.js'; import { Stable } from '@agoric/vats/src/tokens.js'; -import { - mockDProxy, - mockPsmBootstrapArgs, -} from '@agoric/vats/tools/boot-test-utils.js'; import { eventLoopIteration } from '@agoric/zoe/tools/eventLoopIteration.js'; import { E } from '@endo/far'; import { NonNullish } from '@agoric/assert'; @@ -16,6 +12,7 @@ import { coalesceUpdates } from '@agoric/smart-wallet/src/utils.js'; import { INVITATION_MAKERS_DESC } from '../../src/econCommitteeCharter.js'; import { currentPurseBalance, + importBootTestUtils, makeDefaultTestContext, voteForOpenQuestion, } from './contexts.js'; @@ -30,7 +27,11 @@ const test = anyTest; const committeeAddress = 'psmTestAddress'; -const makePsmTestSpace = async log => { +const makePsmTestSpace = async (log, bundleCache) => { + const { mockDProxy, mockPsmBootstrapArgs } = await importBootTestUtils( + log, + bundleCache, + ); const psmParams = { anchorAssets: [{ denom: 'ibc/toyusdc', keyword: 'AUSD' }], economicCommitteeAddresses: { aMember: committeeAddress }, From e1201d1c04d2bc3a3633eb235d194a015139cb14 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Fri, 31 Mar 2023 11:48:38 -0600 Subject: [PATCH 3/4] test(zoe): allow for change in `seat.exit()` message propagation --- .../zoe/test/unitTests/contracts/test-automaticRefund.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zoe/test/unitTests/contracts/test-automaticRefund.js b/packages/zoe/test/unitTests/contracts/test-automaticRefund.js index 639ad42fd4d..fa4a355c02e 100644 --- a/packages/zoe/test/unitTests/contracts/test-automaticRefund.js +++ b/packages/zoe/test/unitTests/contracts/test-automaticRefund.js @@ -315,7 +315,7 @@ test('multiple instances of automaticRefund for the same Zoe', async t => { }); test('zoe - alice tries to complete after completion has already occurred', async t => { - t.plan(5); + t.plan(6); // Setup zoe and mints const { moolaKit, simoleanKit, moola, simoleans, zoe, vatAdminState } = setup(); @@ -350,10 +350,10 @@ test('zoe - alice tries to complete after completion has already occurred', asyn alicePayments, ); - await E(aliceSeat).getOfferResult(); + t.is(await E(aliceSeat).getOfferResult(), 'The offer was accepted'); await t.throwsAsync(() => E(aliceSeat).tryExit(), { - message: /seat has already exited/, + message: /seat has (already|been) exited/, }); const moolaPayout = await aliceSeat.getPayout('ContributionA'); From 66a68179c35768db678e88afb54cb370c66f637e Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 13 Apr 2023 17:21:05 -0600 Subject: [PATCH 4/4] refactor: remove stray references to future `@endo/eventual-send` internals --- packages/vats/src/core/types.js | 2 -- packages/zoe/src/contracts/mintAndSellNFT.js | 1 - packages/zoe/src/zoeService/utils.d.ts | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/vats/src/core/types.js b/packages/vats/src/core/types.js index e1e41632a89..0ed0099fadd 100644 --- a/packages/vats/src/core/types.js +++ b/packages/vats/src/core/types.js @@ -1,7 +1,5 @@ // @ts-check -/** @typedef { import('@endo/eventual-send').EProxy } EProxy */ - /** * This type conflicts with packages/SwingSet/src/vats/plugin-manager.js * diff --git a/packages/zoe/src/contracts/mintAndSellNFT.js b/packages/zoe/src/contracts/mintAndSellNFT.js index 65a0d7619aa..f0735cc30a8 100644 --- a/packages/zoe/src/contracts/mintAndSellNFT.js +++ b/packages/zoe/src/contracts/mintAndSellNFT.js @@ -84,7 +84,6 @@ const start = zcf => { const sellItemsTerms = harden({ pricePerItem, }); - // FIXME EProxy types, startInstance is any const instanceRecordP = E(zoeService).startInstance( sellItemsInstallation, issuerKeywordRecord, diff --git a/packages/zoe/src/zoeService/utils.d.ts b/packages/zoe/src/zoeService/utils.d.ts index cbfcd93b3c1..eabce0d92f7 100644 --- a/packages/zoe/src/zoeService/utils.d.ts +++ b/packages/zoe/src/zoeService/utils.d.ts @@ -1,4 +1,4 @@ -import { Callable } from '@agoric/eventual-send'; +import type { Callable } from '@agoric/internal/src/utils.js'; import type { IssuerKeywordRecord, Payment } from './types.js';