From 21b185f7d5ef46c8911615871ea29bc153b5ea33 Mon Sep 17 00:00:00 2001 From: Chip Morningstar Date: Wed, 27 Sep 2023 17:18:39 -0700 Subject: [PATCH] refactor: give `kmarshal` its own package and remove duplicate implementations --- .github/workflows/test-all-packages.yml | 3 + packages/SwingSet/package.json | 1 + .../SwingSet/src/controller/controller.js | 2 +- .../src/controller/initializeKernel.js | 2 +- .../src/devices/vat-admin/device-vat-admin.js | 2 +- packages/SwingSet/src/kernel/kernel.js | 2 +- packages/SwingSet/src/kernel/kernelQueue.js | 2 +- .../SwingSet/src/kernel/notifyTermination.js | 2 +- .../SwingSet/src/kernel/vat-admin-hooks.js | 2 +- packages/SwingSet/src/lib/capdata.js | 2 +- .../src/lib/makeUndeliverableError.js | 2 +- .../SwingSet/src/vats/comms/controller.js | 2 +- packages/SwingSet/src/vats/comms/delivery.js | 2 +- packages/SwingSet/src/vats/comms/dispatch.js | 2 +- .../SwingSet/test/bundling/test-bundles.js | 3 +- .../test-change-parameters.js | 3 +- packages/SwingSet/test/commsVatDriver.js | 2 +- .../test/definition/test-vat-definition.js | 3 +- .../test/device-hooks/test-device-hooks.js | 3 +- .../device-mailbox/test-device-mailbox.js | 5 +- packages/SwingSet/test/devices/bootstrap-1.js | 2 +- packages/SwingSet/test/devices/bootstrap-4.js | 2 +- .../SwingSet/test/devices/test-devices.js | 4 +- .../SwingSet/test/devices/test-raw-device.js | 2 +- .../test/metering/test-dynamic-vat-metered.js | 3 +- .../metering/test-dynamic-vat-unmetered.js | 3 +- .../test/run-policy/test-run-policy.js | 4 +- packages/SwingSet/test/test-abandon-export.js | 2 +- packages/SwingSet/test/test-comms.js | 4 +- packages/SwingSet/test/test-controller.js | 3 +- packages/SwingSet/test/test-exomessages.js | 3 +- packages/SwingSet/test/test-gc-kernel.js | 3 +- packages/SwingSet/test/test-kernel.js | 3 +- packages/SwingSet/test/test-marshal.js | 2 +- packages/SwingSet/test/test-promises.js | 2 +- packages/SwingSet/test/test-state.js | 4 +- packages/SwingSet/test/test-vpid-kernel.js | 2 +- packages/SwingSet/test/test-xsnap-errors.js | 2 +- packages/SwingSet/test/timer/test-timer.js | 3 +- .../test/transcript/test-state-sync-reload.js | 3 +- .../transcript/test-transcript-entries.js | 3 +- .../test/upgrade/test-upgrade-replay.js | 2 +- .../SwingSet/test/upgrade/test-upgrade.js | 3 +- packages/SwingSet/test/util.js | 2 +- .../terminate/test-terminate-replay.js | 4 +- .../vat-admin/terminate/test-terminate.js | 4 +- .../test/vat-admin/test-create-vat.js | 4 +- .../SwingSet/test/vat-admin/test-replay.js | 4 +- packages/SwingSet/test/vat-direct.js | 2 +- packages/SwingSet/test/vat-syscall-failure.js | 2 +- .../test-vat-timer-upgrade.js | 3 +- packages/SwingSet/test/vat-util.js | 2 +- .../collection-slots/test-collection-slots.js | 4 +- .../delete-stored-vo/test-delete-stored-vo.js | 3 +- .../virtualObjects/test-facet-retention.js | 4 +- .../virtualObjects/test-representatives.js | 2 +- .../virtualObjects/test-weakcollections.js | 2 +- .../vdata-promises/test-vdata-promises.js | 3 +- packages/SwingSet/test/workers/test-worker.js | 3 +- packages/agoric-cli/src/sdk-package-names.js | 1 + packages/boot/package.json | 1 + packages/boot/test/bootstrapTests/supports.ts | 2 +- packages/kmarshal/CHANGELOG.md | 0 packages/kmarshal/package.json | 43 ++++++++++ .../src/lib => kmarshal/src}/kmarshal.js | 0 packages/kmarshal/test/test-basic.js | 20 +++++ packages/kmarshal/tsconfig.json | 12 +++ packages/notifier/package.json | 1 + packages/notifier/test/test-publish-kit.js | 2 +- packages/swingset-liveslots/package.json | 3 +- .../swingset-liveslots/test/gc-helpers.js | 2 +- packages/swingset-liveslots/test/kmarshal.js | 79 ------------------- .../test/liveslots-helpers.js | 4 +- .../test/storeGC/test-lifecycle.js | 2 +- .../test/storeGC/test-refcount-management.js | 2 +- .../test/storeGC/test-weak-key.js | 2 +- .../swingset-liveslots/test/test-baggage.js | 2 +- .../test/test-collection-schema-refcount.js | 2 +- .../test/test-collection-upgrade.js | 2 +- .../test/test-dropped-collection-weakrefs.js | 2 +- .../test/test-gc-sensitivity.js | 2 +- .../test/test-handled-promises.js | 2 +- .../test/test-initial-vrefs.js | 2 +- .../test/test-liveslots-mock-gc.js | 2 +- .../test/test-liveslots-real-gc.js | 2 +- .../swingset-liveslots/test/test-liveslots.js | 2 +- .../test/test-vpid-liveslots.js | 4 +- packages/swingset-liveslots/test/util.js | 2 +- packages/swingset-liveslots/test/vat-util.js | 2 +- .../test/virtual-objects/test-kind-changes.js | 2 +- .../test/virtual-objects/test-state-shape.js | 2 +- .../virtual-objects/test-virtualObjectGC.js | 2 +- .../test-virtualObjectManager.js | 2 +- .../test/virtual-objects/test-vo-real-gc.js | 2 +- .../demo/vatFailure/vat-bad.js | 2 +- packages/swingset-runner/package.json | 1 + packages/zoe/package.json | 1 + .../swingsetTests/zoe/test-zoe-upgrade.js | 2 +- 98 files changed, 187 insertions(+), 192 deletions(-) create mode 100644 packages/kmarshal/CHANGELOG.md create mode 100644 packages/kmarshal/package.json rename packages/{SwingSet/src/lib => kmarshal/src}/kmarshal.js (100%) create mode 100644 packages/kmarshal/test/test-basic.js create mode 100644 packages/kmarshal/tsconfig.json delete mode 100644 packages/swingset-liveslots/test/kmarshal.js diff --git a/.github/workflows/test-all-packages.yml b/.github/workflows/test-all-packages.yml index 50fa4af159d..33558a16e9a 100644 --- a/.github/workflows/test-all-packages.yml +++ b/.github/workflows/test-all-packages.yml @@ -217,6 +217,9 @@ jobs: - name: yarn test (internal) if: (success() || failure()) run: cd packages/internal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT + - name: yarn test (kmarshal) + if: (success() || failure()) + run: cd packages/kmarshal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT - name: yarn test (network) if: (success() || failure()) run: cd packages/network && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT diff --git a/packages/SwingSet/package.json b/packages/SwingSet/package.json index edc1395b5d9..12d05f5b211 100644 --- a/packages/SwingSet/package.json +++ b/packages/SwingSet/package.json @@ -29,6 +29,7 @@ "dependencies": { "@agoric/assert": "^0.6.0", "@agoric/internal": "^0.3.2", + "@agoric/kmarshal": "^0.1.0", "@agoric/store": "^0.9.2", "@agoric/swing-store": "^0.9.1", "@agoric/swingset-liveslots": "^0.10.2", diff --git a/packages/SwingSet/src/controller/controller.js b/packages/SwingSet/src/controller/controller.js index 880b0e9bb65..58661fcab81 100644 --- a/packages/SwingSet/src/controller/controller.js +++ b/packages/SwingSet/src/controller/controller.js @@ -20,7 +20,7 @@ import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js'; import { startSubprocessWorker } from '@agoric/internal/src/lib-nodejs/spawnSubprocessWorker.js'; import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js'; import { makeGcAndFinalize } from '@agoric/internal/src/lib-nodejs/gc-and-finalize.js'; -import { kslot, krefOf } from '../lib/kmarshal.js'; +import { kslot, krefOf } from '@agoric/kmarshal'; import { insistStorageAPI } from '../lib/storageAPI.js'; import { buildKernelBundle, diff --git a/packages/SwingSet/src/controller/initializeKernel.js b/packages/SwingSet/src/controller/initializeKernel.js index 233901e4015..dbf4a74cf10 100644 --- a/packages/SwingSet/src/controller/initializeKernel.js +++ b/packages/SwingSet/src/controller/initializeKernel.js @@ -3,9 +3,9 @@ import { makeMarshal } from '@endo/marshal'; import { Far } from '@endo/far'; import { assert, Fail } from '@agoric/assert'; +import { kser, kunser } from '@agoric/kmarshal'; import { assertKnownOptions } from '../lib/assertOptions.js'; import { insistVatID } from '../lib/id.js'; -import { kser, kunser } from '../lib/kmarshal.js'; import { makeVatSlot } from '../lib/parseVatSlots.js'; import { insistStorageAPI } from '../lib/storageAPI.js'; import { makeVatOptionRecorder } from '../lib/recordVatOptions.js'; diff --git a/packages/SwingSet/src/devices/vat-admin/device-vat-admin.js b/packages/SwingSet/src/devices/vat-admin/device-vat-admin.js index 5edac1d0a97..59e9d583852 100644 --- a/packages/SwingSet/src/devices/vat-admin/device-vat-admin.js +++ b/packages/SwingSet/src/devices/vat-admin/device-vat-admin.js @@ -1,8 +1,8 @@ import { Nat } from '@endo/nat'; import { assert } from '@agoric/assert'; +import { kunser } from '@agoric/kmarshal'; import { buildSerializationTools } from '../lib/deviceTools.js'; import { insistVatID } from '../../lib/id.js'; -import { kunser } from '../../lib/kmarshal.js'; /* diff --git a/packages/SwingSet/src/kernel/kernel.js b/packages/SwingSet/src/kernel/kernel.js index c99e95d0d75..10df109655b 100644 --- a/packages/SwingSet/src/kernel/kernel.js +++ b/packages/SwingSet/src/kernel/kernel.js @@ -2,9 +2,9 @@ import { assert, Fail } from '@agoric/assert'; import { isNat } from '@endo/nat'; import { importBundle } from '@endo/import-bundle'; import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js'; +import { kser, kslot, makeError } from '@agoric/kmarshal'; import { assertKnownOptions } from '../lib/assertOptions.js'; import { foreverPolicy } from '../lib/runPolicies.js'; -import { kser, kslot, makeError } from '../lib/kmarshal.js'; import { makeVatManagerFactory } from './vat-loader/manager-factory.js'; import { makeVatWarehouse } from './vat-warehouse.js'; import makeDeviceManager from './deviceManager.js'; diff --git a/packages/SwingSet/src/kernel/kernelQueue.js b/packages/SwingSet/src/kernel/kernelQueue.js index 471b7cd0293..be025b87b57 100644 --- a/packages/SwingSet/src/kernel/kernelQueue.js +++ b/packages/SwingSet/src/kernel/kernelQueue.js @@ -1,8 +1,8 @@ +import { kser } from '@agoric/kmarshal'; import { insistKernelType, parseKernelSlot } from './parseKernelSlots.js'; import { insistCapData } from '../lib/capdata.js'; import { insistMessage } from '../lib/message.js'; import { insistVatID } from '../lib/id.js'; -import { kser } from '../lib/kmarshal.js'; /** * @param {object} tools diff --git a/packages/SwingSet/src/kernel/notifyTermination.js b/packages/SwingSet/src/kernel/notifyTermination.js index cde53fc706b..38e9d67ce47 100644 --- a/packages/SwingSet/src/kernel/notifyTermination.js +++ b/packages/SwingSet/src/kernel/notifyTermination.js @@ -1,5 +1,5 @@ +import { kunser } from '@agoric/kmarshal'; import { insistCapData } from '../lib/capdata.js'; -import { kunser } from '../lib/kmarshal.js'; /** * @param {string} vatID diff --git a/packages/SwingSet/src/kernel/vat-admin-hooks.js b/packages/SwingSet/src/kernel/vat-admin-hooks.js index c441bc80af0..35045111b0f 100644 --- a/packages/SwingSet/src/kernel/vat-admin-hooks.js +++ b/packages/SwingSet/src/kernel/vat-admin-hooks.js @@ -1,6 +1,6 @@ import { assert } from '@agoric/assert'; +import { kser, kunser } from '@agoric/kmarshal'; import { insistVatID } from '../lib/id.js'; -import { kser, kunser } from '../lib/kmarshal.js'; export function makeVatAdminHooks(tools) { const { kernelKeeper, terminateVat } = tools; diff --git a/packages/SwingSet/src/lib/capdata.js b/packages/SwingSet/src/lib/capdata.js index f0e76e701d0..bbbfbbbf621 100644 --- a/packages/SwingSet/src/lib/capdata.js +++ b/packages/SwingSet/src/lib/capdata.js @@ -1,6 +1,6 @@ import { Fail } from '@agoric/assert'; import { passStyleOf } from '@endo/far'; -import { kunser, krefOf } from './kmarshal.js'; +import { kunser, krefOf } from '@agoric/kmarshal'; /* eslint-disable jsdoc/require-returns-check */ /** diff --git a/packages/SwingSet/src/lib/makeUndeliverableError.js b/packages/SwingSet/src/lib/makeUndeliverableError.js index 51521e63191..ce9dcec410d 100644 --- a/packages/SwingSet/src/lib/makeUndeliverableError.js +++ b/packages/SwingSet/src/lib/makeUndeliverableError.js @@ -11,7 +11,7 @@ // "data is not callable" error is kind of unique to the way swingset handles // references, so we create a distinct error message. -import { kunser, kser } from './kmarshal.js'; +import { kunser, kser } from '@agoric/kmarshal'; export function makeUndeliverableError(methargs) { const method = kunser(methargs)[0]; diff --git a/packages/SwingSet/src/vats/comms/controller.js b/packages/SwingSet/src/vats/comms/controller.js index db0b737285f..e914c742d7b 100644 --- a/packages/SwingSet/src/vats/comms/controller.js +++ b/packages/SwingSet/src/vats/comms/controller.js @@ -1,6 +1,6 @@ import { Nat } from '@endo/nat'; import { assert, Fail } from '@agoric/assert'; -import { kser, kunser, kslot, krefOf } from '../../lib/kmarshal.js'; +import { kser, kunser, kslot, krefOf } from '@agoric/kmarshal'; // deliverToController() is used for local vats which want to talk to us as a // vat, rather than as a conduit to talk to remote vats. The bootstrap diff --git a/packages/SwingSet/src/vats/comms/delivery.js b/packages/SwingSet/src/vats/comms/delivery.js index 13ec3ffcd95..b8b624e5d2a 100644 --- a/packages/SwingSet/src/vats/comms/delivery.js +++ b/packages/SwingSet/src/vats/comms/delivery.js @@ -1,12 +1,12 @@ /* eslint-disable no-use-before-define */ import { assert, Fail } from '@agoric/assert'; +import { kser } from '@agoric/kmarshal'; import { parseLocalSlot, insistLocalType } from './parseLocalSlots.js'; import { makeUndeliverableError } from '../../lib/makeUndeliverableError.js'; import { extractSingleSlot, insistCapData } from '../../lib/capdata.js'; import { insistRemoteType } from './parseRemoteSlot.js'; import { insistRemoteID } from './remote.js'; -import { kser } from '../../lib/kmarshal.js'; export function makeDeliveryKit( state, diff --git a/packages/SwingSet/src/vats/comms/dispatch.js b/packages/SwingSet/src/vats/comms/dispatch.js index 9f7e5799170..5480dabc5ce 100644 --- a/packages/SwingSet/src/vats/comms/dispatch.js +++ b/packages/SwingSet/src/vats/comms/dispatch.js @@ -1,10 +1,10 @@ import { assert, Fail } from '@agoric/assert'; +import { kser, kunser } from '@agoric/kmarshal'; import { makeVatSlot } from '../../lib/parseVatSlots.js'; import { insistMessage } from '../../lib/message.js'; import { makeState } from './state.js'; import { deliverToController } from './controller.js'; import { insistCapData } from '../../lib/capdata.js'; -import { kser, kunser } from '../../lib/kmarshal.js'; import { makeCListKit } from './clist.js'; import { makeDeliveryKit } from './delivery.js'; diff --git a/packages/SwingSet/test/bundling/test-bundles.js b/packages/SwingSet/test/bundling/test-bundles.js index 137ce9b8a0d..c3c3d85b495 100644 --- a/packages/SwingSet/test/bundling/test-bundles.js +++ b/packages/SwingSet/test/bundling/test-bundles.js @@ -2,13 +2,12 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import fs from 'fs'; import bundleSource from '@endo/bundle-source'; import { assert } from '@agoric/assert'; +import { kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; -import { kunser, krefOf } from '../../src/lib/kmarshal.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/change-parameters/test-change-parameters.js b/packages/SwingSet/test/change-parameters/test-change-parameters.js index 48e22fc24ff..290cba11ca1 100644 --- a/packages/SwingSet/test/change-parameters/test-change-parameters.js +++ b/packages/SwingSet/test/change-parameters/test-change-parameters.js @@ -2,11 +2,10 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { assert } from '@agoric/assert'; +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; -import { kunser } from '../../src/lib/kmarshal.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/commsVatDriver.js b/packages/SwingSet/test/commsVatDriver.js index 9eb9a7d4e7f..8e5ffdadc25 100644 --- a/packages/SwingSet/test/commsVatDriver.js +++ b/packages/SwingSet/test/commsVatDriver.js @@ -1,10 +1,10 @@ // @ts-nocheck import { assert, Fail } from '@agoric/assert'; +import { kslot, kser } from '@agoric/kmarshal'; import buildCommsDispatch from '../src/vats/comms/index.js'; import { debugState } from '../src/vats/comms/dispatch.js'; import { flipRemoteSlot } from '../src/vats/comms/parseRemoteSlot.js'; import { makeMessage, makeResolutions } from './util.js'; -import { kslot, kser } from '../src/lib/kmarshal.js'; // This module provides a power tool for testing the comms vat implementation. // It provides support for injecting events into the comms vat and observing diff --git a/packages/SwingSet/test/definition/test-vat-definition.js b/packages/SwingSet/test/definition/test-vat-definition.js index 0fa550eee2c..dbd266b2de3 100644 --- a/packages/SwingSet/test/definition/test-vat-definition.js +++ b/packages/SwingSet/test/definition/test-vat-definition.js @@ -1,7 +1,8 @@ import { test } from '../../tools/prepare-test-env-ava.js'; +// eslint-disable-next-line import/order +import { kser } from '@agoric/kmarshal'; import { buildVatController } from '../../src/index.js'; -import { kser } from '../../src/lib/kmarshal.js'; test('create with setup and buildRootObject', async t => { const config = { diff --git a/packages/SwingSet/test/device-hooks/test-device-hooks.js b/packages/SwingSet/test/device-hooks/test-device-hooks.js index 3c4243e34e6..d2521cf698c 100644 --- a/packages/SwingSet/test/device-hooks/test-device-hooks.js +++ b/packages/SwingSet/test/device-hooks/test-device-hooks.js @@ -2,8 +2,8 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import bundleSource from '@endo/bundle-source'; +import { kunser, kser, kslot } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { @@ -11,7 +11,6 @@ import { makeSwingsetController, buildKernelBundles, } from '../../src/index.js'; -import { kunser, kser, kslot } from '../../src/lib/kmarshal.js'; function dfile(name) { return new URL(`./${name}`, import.meta.url).pathname; diff --git a/packages/SwingSet/test/device-mailbox/test-device-mailbox.js b/packages/SwingSet/test/device-mailbox/test-device-mailbox.js index a15f569724a..c7091d63824 100644 --- a/packages/SwingSet/test/device-mailbox/test-device-mailbox.js +++ b/packages/SwingSet/test/device-mailbox/test-device-mailbox.js @@ -1,9 +1,9 @@ // @ts-nocheck // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order -import bundleSource from '@endo/bundle-source'; +import bundleSource from '@endo/bundle-source'; +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, @@ -15,7 +15,6 @@ import { buildMailbox, } from '../../src/devices/mailbox/mailbox.js'; import { bundleOpts } from '../util.js'; -import { kunser } from '../../src/lib/kmarshal.js'; test.before(async t => { const kernelBundles = await buildKernelBundles(); diff --git a/packages/SwingSet/test/devices/bootstrap-1.js b/packages/SwingSet/test/devices/bootstrap-1.js index f0ea62a3440..058b5c6b6f4 100644 --- a/packages/SwingSet/test/devices/bootstrap-1.js +++ b/packages/SwingSet/test/devices/bootstrap-1.js @@ -1,6 +1,6 @@ import { Fail } from '@agoric/assert'; +import { kser, kunser, krefOf } from '@agoric/kmarshal'; import { extractMessage } from '../vat-util.js'; -import { kser, kunser, krefOf } from '../../src/lib/kmarshal.js'; export default function setup(syscall, state, _helpers, vatPowers) { const { testLog } = vatPowers; diff --git a/packages/SwingSet/test/devices/bootstrap-4.js b/packages/SwingSet/test/devices/bootstrap-4.js index ad7150017c7..26111b60431 100644 --- a/packages/SwingSet/test/devices/bootstrap-4.js +++ b/packages/SwingSet/test/devices/bootstrap-4.js @@ -1,6 +1,6 @@ +import { kunser, kser, kslot, krefOf } from '@agoric/kmarshal'; import { insistVatType } from '../../src/lib/parseVatSlots.js'; import { extractMessage } from '../vat-util.js'; -import { kunser, kser, kslot, krefOf } from '../../src/lib/kmarshal.js'; // to exercise the error we get when syscall.callNow() is given a promise // identifier, we must bypass liveslots, which would otherwise protect us diff --git a/packages/SwingSet/test/devices/test-devices.js b/packages/SwingSet/test/devices/test-devices.js index 02bbc3ec2d9..7aa66d590db 100644 --- a/packages/SwingSet/test/devices/test-devices.js +++ b/packages/SwingSet/test/devices/test-devices.js @@ -3,8 +3,9 @@ import { test } from '../../tools/prepare-test-env-ava.js'; import bundleSource from '@endo/bundle-source'; -import { initSwingStore } from '@agoric/swing-store'; import { parse } from '@endo/marshal'; +import { kser, kslot } from '@agoric/kmarshal'; +import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, @@ -13,7 +14,6 @@ import { } from '../../src/index.js'; import buildCommand from '../../src/devices/command/command.js'; import { bundleOpts, vstr } from '../util.js'; -import { kser, kslot } from '../../src/lib/kmarshal.js'; function dfile(name) { return new URL(`./${name}`, import.meta.url).pathname; diff --git a/packages/SwingSet/test/devices/test-raw-device.js b/packages/SwingSet/test/devices/test-raw-device.js index 9e79e4c3e3e..75cfa8f649b 100644 --- a/packages/SwingSet/test/devices/test-raw-device.js +++ b/packages/SwingSet/test/devices/test-raw-device.js @@ -5,7 +5,7 @@ import { test } from '../../tools/prepare-test-env-ava.js'; // eslint-disable-next-line import/order import bundleSource from '@endo/bundle-source'; import { initSwingStore } from '@agoric/swing-store'; -import { kunser } from '../../src/lib/kmarshal.js'; +import { kunser } from '@agoric/kmarshal'; import { initializeSwingset, diff --git a/packages/SwingSet/test/metering/test-dynamic-vat-metered.js b/packages/SwingSet/test/metering/test-dynamic-vat-metered.js index 3839c5f94c1..e3157b3f19b 100644 --- a/packages/SwingSet/test/metering/test-dynamic-vat-metered.js +++ b/packages/SwingSet/test/metering/test-dynamic-vat-metered.js @@ -2,12 +2,11 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import bundleSource from '@endo/bundle-source'; +import { kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildKernelBundles, buildVatController } from '../../src/index.js'; import { restartVatAdminVat } from '../util.js'; -import { kunser, krefOf } from '../../src/lib/kmarshal.js'; import { enumeratePrefixedKeys } from '../../src/kernel/state/storageHelper.js'; async function prepare() { diff --git a/packages/SwingSet/test/metering/test-dynamic-vat-unmetered.js b/packages/SwingSet/test/metering/test-dynamic-vat-unmetered.js index 42e3f96bee4..d4b759ee385 100644 --- a/packages/SwingSet/test/metering/test-dynamic-vat-unmetered.js +++ b/packages/SwingSet/test/metering/test-dynamic-vat-unmetered.js @@ -1,9 +1,8 @@ -// eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; // eslint-disable-next-line import/order +import { kunser } from '@agoric/kmarshal'; import { buildVatController } from '../../src/index.js'; -import { kunser } from '../../src/lib/kmarshal.js'; // Dynamic vats are created without metering by default diff --git a/packages/SwingSet/test/run-policy/test-run-policy.js b/packages/SwingSet/test/run-policy/test-run-policy.js index 2a7838ae432..a76d17785b2 100644 --- a/packages/SwingSet/test/run-policy/test-run-policy.js +++ b/packages/SwingSet/test/run-policy/test-run-policy.js @@ -1,7 +1,8 @@ // @ts-nocheck +// eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order +import { kslot, kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import { @@ -9,7 +10,6 @@ import { computronCounter, wallClockWaiter, } from '../../src/lib/runPolicies.js'; -import { kslot, kser } from '../../src/lib/kmarshal.js'; async function testCranks(t, mode) { /** @type {SwingSetConfig} */ diff --git a/packages/SwingSet/test/test-abandon-export.js b/packages/SwingSet/test/test-abandon-export.js index df9d76eb771..55d3762e22e 100644 --- a/packages/SwingSet/test/test-abandon-export.js +++ b/packages/SwingSet/test/test-abandon-export.js @@ -6,7 +6,7 @@ import buildKernel from '../src/kernel/index.js'; import { initializeKernel } from '../src/controller/initializeKernel.js'; import { extractMethod } from '../src/lib/kdebug.js'; import { makeKernelEndowments, buildDispatch } from './util.js'; -import { kser, kunser, kslot } from '../src/lib/kmarshal.js'; +import { kser, kunser, kslot } from '@agoric/kmarshal'; const makeKernel = async () => { const endowments = makeKernelEndowments(); diff --git a/packages/SwingSet/test/test-comms.js b/packages/SwingSet/test/test-comms.js index fc84afcbd17..2c76f65fb24 100644 --- a/packages/SwingSet/test/test-comms.js +++ b/packages/SwingSet/test/test-comms.js @@ -1,7 +1,8 @@ // @ts-nocheck -// eslint-disable-next-line import/order import { test } from '../tools/prepare-test-env-ava.js'; +// eslint-disable-next-line import/order +import { kser, kslot } from '@agoric/kmarshal'; import buildCommsDispatch from '../src/vats/comms/index.js'; import { flipRemoteSlot } from '../src/vats/comms/parseRemoteSlot.js'; import { makeState } from '../src/vats/comms/state.js'; @@ -15,7 +16,6 @@ import { makeRetireImports, } from './util.js'; import { commsVatDriver } from './commsVatDriver.js'; -import { kser, kslot } from '../src/lib/kmarshal.js'; test('translation', t => { const s = makeState(null); diff --git a/packages/SwingSet/test/test-controller.js b/packages/SwingSet/test/test-controller.js index 818bbceabbd..e731182d6fc 100644 --- a/packages/SwingSet/test/test-controller.js +++ b/packages/SwingSet/test/test-controller.js @@ -2,8 +2,8 @@ // eslint-disable-next-line import/order import { test } from '../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { spawn } from 'child_process'; +import { kser, kunser, kslot } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildVatController, @@ -12,7 +12,6 @@ import { makeSwingsetController, } from '../src/index.js'; import { checkKT } from './util.js'; -import { kser, kunser, kslot } from '../src/lib/kmarshal.js'; const emptyVP = kser({}); diff --git a/packages/SwingSet/test/test-exomessages.js b/packages/SwingSet/test/test-exomessages.js index 34474873c8e..594a63d8305 100644 --- a/packages/SwingSet/test/test-exomessages.js +++ b/packages/SwingSet/test/test-exomessages.js @@ -1,7 +1,8 @@ import { test } from '../tools/prepare-test-env-ava.js'; +// eslint-disable-next-line import/order +import { kunser, kslot, krefOf } from '@agoric/kmarshal'; import { buildVatController } from '../src/index.js'; -import { kunser, kslot, krefOf } from '../src/lib/kmarshal.js'; async function beginning(t, mode) { const config = { diff --git a/packages/SwingSet/test/test-gc-kernel.js b/packages/SwingSet/test/test-gc-kernel.js index d841bd85b08..640462f5561 100644 --- a/packages/SwingSet/test/test-gc-kernel.js +++ b/packages/SwingSet/test/test-gc-kernel.js @@ -5,8 +5,8 @@ import anylogger from 'anylogger'; // eslint-disable-next-line import/order import { test } from '../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { assert } from '@agoric/assert'; +import { kser, kunser, kslot } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js'; import { parseVatSlot } from '../src/lib/parseVatSlots.js'; @@ -24,7 +24,6 @@ import { makeRetireExports, makeRetireImports, } from './util.js'; -import { kser, kunser, kslot } from '../src/lib/kmarshal.js'; function makeConsole(tag) { const log = anylogger(tag); diff --git a/packages/SwingSet/test/test-kernel.js b/packages/SwingSet/test/test-kernel.js index 5eb45924d94..81e734fd66e 100644 --- a/packages/SwingSet/test/test-kernel.js +++ b/packages/SwingSet/test/test-kernel.js @@ -2,13 +2,12 @@ // eslint-disable-next-line import/order import { test } from '../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { Fail } from '@agoric/assert'; +import { kser, kslot } from '@agoric/kmarshal'; import buildKernel from '../src/kernel/index.js'; import { initializeKernel } from '../src/controller/initializeKernel.js'; import { makeVatSlot } from '../src/lib/parseVatSlots.js'; import { checkKT, extractMessage, makeKernelEndowments } from './util.js'; -import { kser, kslot } from '../src/lib/kmarshal.js'; function oneResolution(promiseID, rejected, data) { return [[promiseID, rejected, data]]; diff --git a/packages/SwingSet/test/test-marshal.js b/packages/SwingSet/test/test-marshal.js index 7655cfe9d88..6e1a8d673ca 100644 --- a/packages/SwingSet/test/test-marshal.js +++ b/packages/SwingSet/test/test-marshal.js @@ -4,10 +4,10 @@ import { test } from '../tools/prepare-test-env-ava.js'; import { Far } from '@endo/far'; import { makePromiseKit } from '@endo/promise-kit'; +import { kser, makeError } from '@agoric/kmarshal'; import { makeMarshaller } from '@agoric/swingset-liveslots'; import { makeDummyMeterControl } from '../src/kernel/dummyMeterControl.js'; -import { kser, makeError } from '../src/lib/kmarshal.js'; const gcTools = harden({ WeakRef, diff --git a/packages/SwingSet/test/test-promises.js b/packages/SwingSet/test/test-promises.js index f4effda6b08..6d6a73712e7 100644 --- a/packages/SwingSet/test/test-promises.js +++ b/packages/SwingSet/test/test-promises.js @@ -2,12 +2,12 @@ import { test } from '../tools/prepare-test-env-ava.js'; // eslint-disable-next-line import/order +import { kser, kslot, kunser } from '@agoric/kmarshal'; import { buildVatController, loadBasedir, buildKernelBundles, } from '../src/index.js'; -import { kser, kslot, kunser } from '../src/lib/kmarshal.js'; const bfile = name => new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/test-state.js b/packages/SwingSet/test/test-state.js index 40ea95f0749..690e0647a8f 100644 --- a/packages/SwingSet/test/test-state.js +++ b/packages/SwingSet/test/test-state.js @@ -2,13 +2,13 @@ /* eslint-disable no-useless-concat */ // eslint-disable-next-line import/order import { test } from '../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order + import { createHash } from 'crypto'; +import { kser, kslot } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import makeKernelKeeper from '../src/kernel/state/kernelKeeper.js'; import { makeKernelStats } from '../src/kernel/state/stats.js'; import { KERNEL_STATS_METRICS } from '../src/kernel/metrics.js'; -import { kser, kslot } from '../src/lib/kmarshal.js'; import { enumeratePrefixedKeys, getPrefixedValues, diff --git a/packages/SwingSet/test/test-vpid-kernel.js b/packages/SwingSet/test/test-vpid-kernel.js index d34ccb359e7..b8b03997c8b 100644 --- a/packages/SwingSet/test/test-vpid-kernel.js +++ b/packages/SwingSet/test/test-vpid-kernel.js @@ -5,12 +5,12 @@ import { test } from '../tools/prepare-test-env-ava.js'; import anylogger from 'anylogger'; import { Fail } from '@agoric/assert'; +import { kser, kslot } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js'; import buildKernel from '../src/kernel/index.js'; import { initializeKernel } from '../src/controller/initializeKernel.js'; -import { kser, kslot } from '../src/lib/kmarshal.js'; import { buildDispatch } from './util.js'; diff --git a/packages/SwingSet/test/test-xsnap-errors.js b/packages/SwingSet/test/test-xsnap-errors.js index 8b41b23dad1..4eb6e3f404b 100644 --- a/packages/SwingSet/test/test-xsnap-errors.js +++ b/packages/SwingSet/test/test-xsnap-errors.js @@ -6,6 +6,7 @@ import { spawn } from 'child_process'; import fs from 'fs'; import { tmpName } from 'tmp'; import bundleSource from '@endo/bundle-source'; +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { makeXsSubprocessFactory } from '../src/kernel/vat-loader/manager-subprocess-xsnap.js'; @@ -14,7 +15,6 @@ import { makeXsnapBundleData, } from '../src/controller/bundle-handler.js'; import { makeStartXSnap } from '../src/controller/startXSnap.js'; -import { kser } from '../src/lib/kmarshal.js'; test('child termination distinguished from meter exhaustion', async t => { /** @type { ReturnType } */ diff --git a/packages/SwingSet/test/timer/test-timer.js b/packages/SwingSet/test/timer/test-timer.js index 49f3c293638..2df4742240a 100644 --- a/packages/SwingSet/test/timer/test-timer.js +++ b/packages/SwingSet/test/timer/test-timer.js @@ -1,11 +1,10 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import { buildTimer } from '../../src/devices/timer/timer.js'; -import { kunser } from '../../src/lib/kmarshal.js'; const bfile = name => new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/transcript/test-state-sync-reload.js b/packages/SwingSet/test/transcript/test-state-sync-reload.js index 83e9b983e52..ec6af96d47c 100644 --- a/packages/SwingSet/test/transcript/test-state-sync-reload.js +++ b/packages/SwingSet/test/transcript/test-state-sync-reload.js @@ -1,7 +1,9 @@ // @ts-nocheck /* eslint @typescript-eslint/no-floating-promises: "warn" */ import test from 'ava'; + import tmp from 'tmp'; +import { kunser } from '@agoric/kmarshal'; import { initSwingStore, makeSwingStoreExporter, @@ -9,7 +11,6 @@ import { } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import { buildKernelBundle } from '../../src/controller/initializeSwingset.js'; -import { kunser } from '../../src/lib/kmarshal.js'; /** * @param {string} [prefix] diff --git a/packages/SwingSet/test/transcript/test-transcript-entries.js b/packages/SwingSet/test/transcript/test-transcript-entries.js index aad87dedb7e..36b7cded0e2 100644 --- a/packages/SwingSet/test/transcript/test-transcript-entries.js +++ b/packages/SwingSet/test/transcript/test-transcript-entries.js @@ -1,10 +1,11 @@ // @ts-nocheck /* eslint @typescript-eslint/no-floating-promises: "warn" */ import test from 'ava'; + +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import { buildKernelBundle } from '../../src/controller/initializeSwingset.js'; -import { kunser } from '../../src/lib/kmarshal.js'; const bfile = name => new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/upgrade/test-upgrade-replay.js b/packages/SwingSet/test/upgrade/test-upgrade-replay.js index b8ec534896c..6c02487e833 100644 --- a/packages/SwingSet/test/upgrade/test-upgrade-replay.js +++ b/packages/SwingSet/test/upgrade/test-upgrade-replay.js @@ -3,6 +3,7 @@ import { test } from '../../tools/prepare-test-env-ava.js'; import { assert } from '@agoric/assert'; +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildKernelBundles, @@ -10,7 +11,6 @@ import { makeSwingsetController, } from '../../src/index.js'; import { bundleOpts } from '../util.js'; -import { kser } from '../../src/lib/kmarshal.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/upgrade/test-upgrade.js b/packages/SwingSet/test/upgrade/test-upgrade.js index f5641617e60..d30fc45e676 100644 --- a/packages/SwingSet/test/upgrade/test-upgrade.js +++ b/packages/SwingSet/test/upgrade/test-upgrade.js @@ -2,14 +2,13 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { assert } from '@agoric/assert'; import bundleSource from '@endo/bundle-source'; import { objectMap } from '@agoric/internal'; +import { kser, kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { parseReachableAndVatSlot } from '../../src/kernel/state/reachable.js'; import { parseVatSlot } from '../../src/lib/parseVatSlots.js'; -import { kser, kunser, krefOf } from '../../src/lib/kmarshal.js'; import { buildKernelBundles, initializeSwingset, diff --git a/packages/SwingSet/test/util.js b/packages/SwingSet/test/util.js index 669ce24252c..aedaab707b8 100644 --- a/packages/SwingSet/test/util.js +++ b/packages/SwingSet/test/util.js @@ -3,10 +3,10 @@ import anylogger from 'anylogger'; import bundleSource from '@endo/bundle-source'; +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js'; import { extractMessage, ignore, vstr } from './vat-util.js'; -import { kser } from '../src/lib/kmarshal.js'; export { extractMessage, ignore, vstr }; diff --git a/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js b/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js index 45e4c17c374..aaa555ed2d5 100644 --- a/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js +++ b/packages/SwingSet/test/vat-admin/terminate/test-terminate-replay.js @@ -1,7 +1,8 @@ // @ts-nocheck // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order + +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { @@ -9,7 +10,6 @@ import { loadSwingsetConfigFile, buildKernelBundles, } from '../../../src/index.js'; -import { kser } from '../../../src/lib/kmarshal.js'; test.before(async t => { const kernelBundles = await buildKernelBundles(); diff --git a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js index c4e194a0c97..750862e084b 100644 --- a/packages/SwingSet/test/vat-admin/terminate/test-terminate.js +++ b/packages/SwingSet/test/vat-admin/terminate/test-terminate.js @@ -1,7 +1,8 @@ // @ts-nocheck // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order + +import { kser, kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { @@ -9,7 +10,6 @@ import { loadSwingsetConfigFile, buildKernelBundles, } from '../../../src/index.js'; -import { kser, kunser } from '../../../src/lib/kmarshal.js'; import { enumeratePrefixedKeys } from '../../../src/kernel/state/storageHelper.js'; import { restartVatAdminVat } from '../../util.js'; diff --git a/packages/SwingSet/test/vat-admin/test-create-vat.js b/packages/SwingSet/test/vat-admin/test-create-vat.js index c853bd85c92..a23a686752e 100644 --- a/packages/SwingSet/test/vat-admin/test-create-vat.js +++ b/packages/SwingSet/test/vat-admin/test-create-vat.js @@ -1,8 +1,9 @@ // @ts-nocheck // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order + import bundleSource from '@endo/bundle-source'; +import { kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildKernelBundles, @@ -11,7 +12,6 @@ import { loadBasedir, } from '../../src/index.js'; import { bundleOpts, restartVatAdminVat } from '../util.js'; -import { kunser, krefOf } from '../../src/lib/kmarshal.js'; import { extractMethod } from '../../src/lib/kdebug.js'; function nonBundleFunction(_E) { diff --git a/packages/SwingSet/test/vat-admin/test-replay.js b/packages/SwingSet/test/vat-admin/test-replay.js index 6011f7a9363..24cb2dfd24f 100644 --- a/packages/SwingSet/test/vat-admin/test-replay.js +++ b/packages/SwingSet/test/vat-admin/test-replay.js @@ -1,10 +1,10 @@ // @ts-nocheck // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order + +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildKernelBundles, buildVatController } from '../../src/index.js'; -import { kser } from '../../src/lib/kmarshal.js'; function copy(data) { return JSON.parse(JSON.stringify(data)); diff --git a/packages/SwingSet/test/vat-direct.js b/packages/SwingSet/test/vat-direct.js index 52bfd3c2d4a..a9121801b92 100644 --- a/packages/SwingSet/test/vat-direct.js +++ b/packages/SwingSet/test/vat-direct.js @@ -1,6 +1,6 @@ // @ts-nocheck +import { krefOf, kser, kslot, kunser } from '@agoric/kmarshal'; import { extractMessage } from './vat-util.js'; -import { krefOf, kser, kslot, kunser } from '../src/lib/kmarshal.js'; /** * A testing vat that generically exposes kernel interactions diff --git a/packages/SwingSet/test/vat-syscall-failure.js b/packages/SwingSet/test/vat-syscall-failure.js index 861c73e399e..4c1af219fda 100644 --- a/packages/SwingSet/test/vat-syscall-failure.js +++ b/packages/SwingSet/test/vat-syscall-failure.js @@ -1,5 +1,5 @@ +import { kser } from '@agoric/kmarshal'; import { extractMessage } from './vat-util.js'; -import { kser } from '../src/lib/kmarshal.js'; export default function setup(syscall, _state, _helpers, vatPowers) { function dispatch(vatDeliverObject) { diff --git a/packages/SwingSet/test/vat-timer-upgrade/test-vat-timer-upgrade.js b/packages/SwingSet/test/vat-timer-upgrade/test-vat-timer-upgrade.js index 60613c555f2..138a203c161 100644 --- a/packages/SwingSet/test/vat-timer-upgrade/test-vat-timer-upgrade.js +++ b/packages/SwingSet/test/vat-timer-upgrade/test-vat-timer-upgrade.js @@ -1,12 +1,11 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import bundleSource from '@endo/bundle-source'; +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import { buildTimer } from '../../src/devices/timer/timer.js'; -import { kunser } from '../../src/lib/kmarshal.js'; const bfile = name => new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/vat-util.js b/packages/SwingSet/test/vat-util.js index ee55521b73f..e03fdcf3c97 100644 --- a/packages/SwingSet/test/vat-util.js +++ b/packages/SwingSet/test/vat-util.js @@ -2,7 +2,7 @@ // modules import { assert } from '@agoric/assert'; -import { kser, kunser } from '../src/lib/kmarshal.js'; +import { kser, kunser } from '@agoric/kmarshal'; export function extractMessage(vatDeliverObject) { const [type, ...vdoargs] = vatDeliverObject; diff --git a/packages/SwingSet/test/virtualObjects/collection-slots/test-collection-slots.js b/packages/SwingSet/test/virtualObjects/collection-slots/test-collection-slots.js index d69a960a079..f0d629a86e7 100644 --- a/packages/SwingSet/test/virtualObjects/collection-slots/test-collection-slots.js +++ b/packages/SwingSet/test/virtualObjects/collection-slots/test-collection-slots.js @@ -2,8 +2,8 @@ // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { assert } from '@agoric/assert'; +import { kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { parseReachableAndVatSlot } from '../../../src/kernel/state/reachable.js'; import { @@ -11,8 +11,6 @@ import { makeSwingsetController, } from '../../../src/index.js'; -import { kunser, krefOf } from '../../../src/lib/kmarshal.js'; - function bfile(name) { return new URL(name, import.meta.url).pathname; } diff --git a/packages/SwingSet/test/virtualObjects/delete-stored-vo/test-delete-stored-vo.js b/packages/SwingSet/test/virtualObjects/delete-stored-vo/test-delete-stored-vo.js index 12025568f13..291c664f51b 100644 --- a/packages/SwingSet/test/virtualObjects/delete-stored-vo/test-delete-stored-vo.js +++ b/packages/SwingSet/test/virtualObjects/delete-stored-vo/test-delete-stored-vo.js @@ -2,15 +2,14 @@ // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order import { assert } from '@agoric/assert'; +import { kunser, krefOf } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { parseReachableAndVatSlot } from '../../../src/kernel/state/reachable.js'; import { initializeSwingset, makeSwingsetController, } from '../../../src/index.js'; -import { kunser, krefOf } from '../../../src/lib/kmarshal.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/virtualObjects/test-facet-retention.js b/packages/SwingSet/test/virtualObjects/test-facet-retention.js index 05d1cc03b4d..389fb6f12bd 100644 --- a/packages/SwingSet/test/virtualObjects/test-facet-retention.js +++ b/packages/SwingSet/test/virtualObjects/test-facet-retention.js @@ -1,10 +1,10 @@ // @ts-nocheck import test from 'ava'; + +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { buildVatController } from '../../src/index.js'; -import { kunser } from '../../src/lib/kmarshal.js'; - // Check that facets which don't reference their state still keep their cohort alive // Test what happens when userspace builds recognizers for various VO diff --git a/packages/SwingSet/test/virtualObjects/test-representatives.js b/packages/SwingSet/test/virtualObjects/test-representatives.js index 12e2395fdd3..0a9a8b812c9 100644 --- a/packages/SwingSet/test/virtualObjects/test-representatives.js +++ b/packages/SwingSet/test/virtualObjects/test-representatives.js @@ -2,6 +2,7 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; +import { kser, kslot } from '@agoric/kmarshal'; import { M } from '@agoric/store'; import { initSwingStore } from '@agoric/swing-store'; import { @@ -11,7 +12,6 @@ import { } from '../../src/index.js'; import makeNextLog from '../make-nextlog.js'; -import { kser, kslot } from '../../src/lib/kmarshal.js'; import { enumeratePrefixedKeys } from '../../src/kernel/state/storageHelper.js'; import { vstr } from '../util.js'; diff --git a/packages/SwingSet/test/virtualObjects/test-weakcollections.js b/packages/SwingSet/test/virtualObjects/test-weakcollections.js index 88dcb8a3a61..d6a401ff927 100644 --- a/packages/SwingSet/test/virtualObjects/test-weakcollections.js +++ b/packages/SwingSet/test/virtualObjects/test-weakcollections.js @@ -1,11 +1,11 @@ // eslint-disable-next-line import/order import { test } from '../../tools/prepare-test-env-ava.js'; +import { kser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js'; import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; import makeNextLog from '../make-nextlog.js'; -import { kser } from '../../src/lib/kmarshal.js'; test('weakMap in vat', async t => { const config = { diff --git a/packages/SwingSet/test/virtualObjects/vdata-promises/test-vdata-promises.js b/packages/SwingSet/test/virtualObjects/vdata-promises/test-vdata-promises.js index 6c8676586d5..6d7bf9aa666 100644 --- a/packages/SwingSet/test/virtualObjects/vdata-promises/test-vdata-promises.js +++ b/packages/SwingSet/test/virtualObjects/vdata-promises/test-vdata-promises.js @@ -1,14 +1,13 @@ // eslint-disable-next-line import/order import { test } from '../../../tools/prepare-test-env-ava.js'; -// eslint-disable-next-line import/order +import { kunser } from '@agoric/kmarshal'; import { initSwingStore } from '@agoric/swing-store'; import { parseReachableAndVatSlot } from '../../../src/kernel/state/reachable.js'; import { initializeSwingset, makeSwingsetController, } from '../../../src/index.js'; -import { kunser } from '../../../src/lib/kmarshal.js'; function bfile(name) { return new URL(name, import.meta.url).pathname; diff --git a/packages/SwingSet/test/workers/test-worker.js b/packages/SwingSet/test/workers/test-worker.js index c1750779b12..ec49a67e0ff 100644 --- a/packages/SwingSet/test/workers/test-worker.js +++ b/packages/SwingSet/test/workers/test-worker.js @@ -1,7 +1,8 @@ import { test } from '../../tools/prepare-test-env-ava.js'; +// eslint-disable-next-line import/order +import { kunser } from '@agoric/kmarshal'; import { loadBasedir, buildVatController } from '../../src/index.js'; -import { kunser } from '../../src/lib/kmarshal.js'; const expected = [ ['B good', 'C good', 'F good', 'three good', 'exit good', 'exitWF good'], diff --git a/packages/agoric-cli/src/sdk-package-names.js b/packages/agoric-cli/src/sdk-package-names.js index a4371b52d2d..2db4676d928 100644 --- a/packages/agoric-cli/src/sdk-package-names.js +++ b/packages/agoric-cli/src/sdk-package-names.js @@ -20,6 +20,7 @@ export default [ "@agoric/import-manager", "@agoric/inter-protocol", "@agoric/internal", + "@agoric/kmarshal", "@agoric/network", "@agoric/notifier", "@agoric/pegasus", diff --git a/packages/boot/package.json b/packages/boot/package.json index 7fecc1ace84..570a86cd7a7 100644 --- a/packages/boot/package.json +++ b/packages/boot/package.json @@ -42,6 +42,7 @@ "@agoric/deploy-script-support": "^0.10.3", "@agoric/governance": "^0.10.3", "@agoric/inter-protocol": "^0.16.1", + "@agoric/kmarshal": "^0.1.0", "@agoric/store": "^0.9.2", "@agoric/swing-store": "^0.9.1", "@agoric/swingset-liveslots": "^0.10.2", diff --git a/packages/boot/test/bootstrapTests/supports.ts b/packages/boot/test/bootstrapTests/supports.ts index 9d0e0908ae5..fd245138e76 100644 --- a/packages/boot/test/bootstrapTests/supports.ts +++ b/packages/boot/test/bootstrapTests/supports.ts @@ -14,7 +14,7 @@ import { unmarshalFromVstorage } from '@agoric/internal/src/marshal.js'; import { makeFakeStorageKit } from '@agoric/internal/src/storage-test-utils.js'; import { initSwingStore } from '@agoric/swing-store'; import { loadSwingsetConfigFile } from '@agoric/swingset-vat'; -import { krefOf, kunser } from '@agoric/swingset-vat/src/lib/kmarshal.js'; +import { krefOf, kunser } from '@agoric/kmarshal'; import { TimeMath, Timestamp } from '@agoric/time'; import { boardSlottingMarshaller, diff --git a/packages/kmarshal/CHANGELOG.md b/packages/kmarshal/CHANGELOG.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/kmarshal/package.json b/packages/kmarshal/package.json new file mode 100644 index 00000000000..493c73f7443 --- /dev/null +++ b/packages/kmarshal/package.json @@ -0,0 +1,43 @@ +{ + "name": "@agoric/kmarshal", + "version": "0.1.0", + "description": "Token-only marshaller for kernel and tests", + "type": "module", + "main": "./src/kmarshal.js", + "exports": { + ".": "./src/kmarshal.js" + }, + "repository": "https://github.com/Agoric/agoric-sdk", + "author": "Agoric", + "license": "Apache-2.0", + "scripts": { + "build": "exit 0", + "test": "ava", + "test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js", + "test:xs": "exit 0", + "lint-fix": "yarn lint:eslint --fix", + "lint": "run-s --continue-on-error lint:*", + "lint:types": "tsc", + "lint:eslint": "eslint ." + }, + "dependencies": { + "@endo/far": "^0.2.21", + "@endo/marshal": "^0.8.8", + "@agoric/assert": "^0.6.0" + }, + "devDependencies": { + "ava": "^5.3.0" + }, + "publishConfig": { + "access": "public" + }, + "ava": { + "files": [ + "test/**/test-*.js" + ], + "require": [ + "@endo/init/debug.js" + ], + "timeout": "2m" + } +} diff --git a/packages/SwingSet/src/lib/kmarshal.js b/packages/kmarshal/src/kmarshal.js similarity index 100% rename from packages/SwingSet/src/lib/kmarshal.js rename to packages/kmarshal/src/kmarshal.js diff --git a/packages/kmarshal/test/test-basic.js b/packages/kmarshal/test/test-basic.js new file mode 100644 index 00000000000..0fe1a54ed07 --- /dev/null +++ b/packages/kmarshal/test/test-basic.js @@ -0,0 +1,20 @@ +import test from 'ava'; + +import { kser, kunser, krefOf, kslot } from '../src/kmarshal.js'; + +test('sanity check', t => { + const assertRoundTrip = (val, toComparable = v => v) => { + const ser = kser(val); + t.not(ser, val); + const unser = kunser(ser); + t.is(toComparable(unser), toComparable(val)); + }; + assertRoundTrip(undefined); + assertRoundTrip(47); + assertRoundTrip(-2n); + assertRoundTrip('foo'); + + const remotable = kslot('ko47'); + t.is(krefOf(remotable), 'ko47'); + assertRoundTrip(remotable, krefOf); +}); diff --git a/packages/kmarshal/tsconfig.json b/packages/kmarshal/tsconfig.json new file mode 100644 index 00000000000..282b3f23e36 --- /dev/null +++ b/packages/kmarshal/tsconfig.json @@ -0,0 +1,12 @@ +// This file can contain .js-specific Typescript compiler config. +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "maxNodeModuleJsDepth": 2, + }, + "include": [ + "src/**/*.js", + "test/**/*.js" + ] +} diff --git a/packages/notifier/package.json b/packages/notifier/package.json index 6fa33635fd7..29fd48e5533 100644 --- a/packages/notifier/package.json +++ b/packages/notifier/package.json @@ -42,6 +42,7 @@ "@endo/promise-kit": "^0.2.59" }, "devDependencies": { + "@agoric/kmarshal": "^0.1.0", "@agoric/swingset-liveslots": "^0.10.2", "@agoric/swing-store": "^0.9.1", "@agoric/swingset-vat": "^0.32.2", diff --git a/packages/notifier/test/test-publish-kit.js b/packages/notifier/test/test-publish-kit.js index 15eb84a8a9c..2a7216bedce 100644 --- a/packages/notifier/test/test-publish-kit.js +++ b/packages/notifier/test/test-publish-kit.js @@ -10,7 +10,7 @@ import { makeSwingsetController, } from '@agoric/swingset-vat'; import { initSwingStore } from '@agoric/swing-store'; -import { kunser } from '@agoric/swingset-vat/src/lib/kmarshal.js'; +import { kunser } from '@agoric/kmarshal'; import { makeScalarBigMapStore } from '@agoric/vat-data/src/vat-data-bindings.js'; import { makePublishKit, diff --git a/packages/swingset-liveslots/package.json b/packages/swingset-liveslots/package.json index dd7d80b4b27..732f6413c68 100644 --- a/packages/swingset-liveslots/package.json +++ b/packages/swingset-liveslots/package.json @@ -31,7 +31,8 @@ "@endo/promise-kit": "^0.2.59" }, "devDependencies": { - "ava": "^5.3.0" + "ava": "^5.3.0", + "@agoric/kmarshal": "^0.1.0" }, "files": [ "src/**/*.js", diff --git a/packages/swingset-liveslots/test/gc-helpers.js b/packages/swingset-liveslots/test/gc-helpers.js index 8736a587895..376ac94365b 100644 --- a/packages/swingset-liveslots/test/gc-helpers.js +++ b/packages/swingset-liveslots/test/gc-helpers.js @@ -2,7 +2,7 @@ import { Far } from '@endo/marshal'; import { M } from '@agoric/store'; -import { kslot, kser } from './kmarshal.js'; +import { kslot, kser } from '@agoric/kmarshal'; import { parseVatSlot } from '../src/parseVatSlots.js'; // These tests follow the model described in diff --git a/packages/swingset-liveslots/test/kmarshal.js b/packages/swingset-liveslots/test/kmarshal.js deleted file mode 100644 index e623b410160..00000000000 --- a/packages/swingset-liveslots/test/kmarshal.js +++ /dev/null @@ -1,79 +0,0 @@ -import { Far, makeMarshal, passStyleOf } from '@endo/marshal'; -import { assert } from '@agoric/assert'; - -// Simple wrapper for serializing and unserializing marshalled values inside the -// kernel, where we don't actually want to use clists nor actually allocate real -// objects, but instead to stay entirely within the domain of krefs. This is -// used to enable syntactic manipulation of serialized values while remaining -// agnostic about the internal details of the serialization encoding. - -const refMap = new WeakMap(); - -export const kslot = (kref, iface) => { - assert.typeof(kref, 'string'); - if (iface && iface.startsWith('Alleged: ')) { - // Encoder prepends "Alleged: " to iface string, but the decoder doesn't strip it - // Unclear whether it's the decoder or me who is wrong - iface = iface.slice(9); - } - if ( - kref.startsWith('p') || - kref.startsWith('kp') || - kref.startsWith('lp') || - kref.startsWith('rp') - ) { - // TODO: temporary hack because smallcaps encodes promise references - // differently from remotable object references, and the current version of - // the smallcaps decoder annoyingly insists that if the encoded body string - // says a slot is a promise, then convertSlotToVal had better by damn return - // an actual Promise, even if, as in the intended use case here, we neither - // want nor need a promise, nor the overhead of a map to keep track of it - // with. This behavior is in service of defense against a hypothesized - // security issue whose exact nature has largely been forgotton in the - // months since it was first encountered. MarkM is currently researching - // what the problem was thought to have been, to see if it is real and to - // understand it if so. This will eventually result in either changes to - // the smallcaps encoding or to the marshal setup API to support the purely - // manipulative use case. In the meantime, this ugliness... - const p = new Promise(() => undefined); - refMap.set(p, kref); - return harden(p); - } else { - const o = Far(iface, { - iface: () => iface, - getKref: () => `${kref}`, - }); - return o; - } -}; - -export const krefOf = obj => { - const fromMap = refMap.get(obj); - if (fromMap) { - return fromMap; - } - // When krefOf() is called as part of kmarshal.serialize, marshal - // will only give it things that are 'remotable' (Promises and the - // Far objects created by kslot()). When krefOf() is called by - // kernel code (as part of extractSingleSlot() or the vat-comms - // equivalent), it ought to throw if 'obj' is not one of the Far - // objects created by our kslot(). - assert.equal(passStyleOf(obj), 'remotable', obj); - const getKref = obj.getKref; - assert.typeof(getKref, 'function'); - return getKref(); -}; - -const kmarshal = makeMarshal(krefOf, kslot, { - serializeBodyFormat: 'smallcaps', - errorTagging: 'off', -}); - -export const kser = value => kmarshal.serialize(harden(value)); - -export const kunser = serializedValue => kmarshal.unserialize(serializedValue); - -export function makeError(message) { - assert.typeof(message, 'string'); - return kser(Error(message)); -} diff --git a/packages/swingset-liveslots/test/liveslots-helpers.js b/packages/swingset-liveslots/test/liveslots-helpers.js index 1f101af07e6..8926bf72d16 100644 --- a/packages/swingset-liveslots/test/liveslots-helpers.js +++ b/packages/swingset-liveslots/test/liveslots-helpers.js @@ -1,6 +1,7 @@ /* global WeakRef, FinalizationRegistry */ -import engineGC from './engine-gc.js'; +import { kser } from '@agoric/kmarshal'; +import engineGC from './engine-gc.js'; import { waitUntilQuiescent } from './waitUntilQuiescent.js'; import { makeGcAndFinalize } from './gc-and-finalize.js'; import { makeDummyMeterControl } from './dummyMeterControl.js'; @@ -12,7 +13,6 @@ import { makeRetireExports, makeBringOutYourDead, } from './util.js'; -import { kser } from './kmarshal.js'; /** * @param {object} [options] diff --git a/packages/swingset-liveslots/test/storeGC/test-lifecycle.js b/packages/swingset-liveslots/test/storeGC/test-lifecycle.js index 62bee16ccdb..2f998917b04 100644 --- a/packages/swingset-liveslots/test/storeGC/test-lifecycle.js +++ b/packages/swingset-liveslots/test/storeGC/test-lifecycle.js @@ -1,12 +1,12 @@ // @ts-nocheck import test from 'ava'; +import { kslot, kunser } from '@agoric/kmarshal'; import { setupTestLiveslots, findSyscallsByType, } from '../liveslots-helpers.js'; import { buildRootObject, mainHeldIdx, mapRef } from '../gc-helpers.js'; -import { kslot, kunser } from '../kmarshal.js'; import { parseVatSlot } from '../../src/parseVatSlots.js'; // These tests follow the model described in diff --git a/packages/swingset-liveslots/test/storeGC/test-refcount-management.js b/packages/swingset-liveslots/test/storeGC/test-refcount-management.js index c5f88d56d61..65fd4aaa426 100644 --- a/packages/swingset-liveslots/test/storeGC/test-refcount-management.js +++ b/packages/swingset-liveslots/test/storeGC/test-refcount-management.js @@ -1,5 +1,6 @@ import test from 'ava'; +import { kslot } from '@agoric/kmarshal'; import { findSyscallsByType, setupTestLiveslots, @@ -11,7 +12,6 @@ import { refValString, assertCollectionDeleted, } from '../gc-helpers.js'; -import { kslot } from '../kmarshal.js'; import { vstr } from '../util.js'; // These tests follow the model described in diff --git a/packages/swingset-liveslots/test/storeGC/test-weak-key.js b/packages/swingset-liveslots/test/storeGC/test-weak-key.js index d5001aa5057..a074705240b 100644 --- a/packages/swingset-liveslots/test/storeGC/test-weak-key.js +++ b/packages/swingset-liveslots/test/storeGC/test-weak-key.js @@ -1,5 +1,6 @@ import test from 'ava'; +import { kslot } from '@agoric/kmarshal'; import { setupTestLiveslots } from '../liveslots-helpers.js'; import { buildRootObject, @@ -7,7 +8,6 @@ import { assertCollectionDeleted, deduceCollectionID, } from '../gc-helpers.js'; -import { kslot } from '../kmarshal.js'; import { vstr } from '../util.js'; // These tests follow the model described in test-virtualObjectGC.js diff --git a/packages/swingset-liveslots/test/test-baggage.js b/packages/swingset-liveslots/test/test-baggage.js index be4b2013514..a1523b647a4 100644 --- a/packages/swingset-liveslots/test/test-baggage.js +++ b/packages/swingset-liveslots/test/test-baggage.js @@ -1,9 +1,9 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kunser } from '@agoric/kmarshal'; import { setupTestLiveslots } from './liveslots-helpers.js'; import { vstr } from './util.js'; -import { kunser } from './kmarshal.js'; import { parseVatSlot } from '../src/parseVatSlots.js'; function buildRootObject(vatPowers, vatParameters, baggage) { diff --git a/packages/swingset-liveslots/test/test-collection-schema-refcount.js b/packages/swingset-liveslots/test/test-collection-schema-refcount.js index 7754e119ab9..e563ecf5227 100644 --- a/packages/swingset-liveslots/test/test-collection-schema-refcount.js +++ b/packages/swingset-liveslots/test/test-collection-schema-refcount.js @@ -1,9 +1,9 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser } from '@agoric/kmarshal'; import { makeLiveSlots } from '../src/liveslots.js'; import { parseVatSlot } from '../src/parseVatSlots.js'; -import { kser } from './kmarshal.js'; import { buildSyscall } from './liveslots-helpers.js'; import { makeStartVat, makeBringOutYourDead } from './util.js'; import { makeMockGC } from './mock-gc.js'; diff --git a/packages/swingset-liveslots/test/test-collection-upgrade.js b/packages/swingset-liveslots/test/test-collection-upgrade.js index e8f1719c7c4..ca329209659 100644 --- a/packages/swingset-liveslots/test/test-collection-upgrade.js +++ b/packages/swingset-liveslots/test/test-collection-upgrade.js @@ -1,10 +1,10 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser } from '@agoric/kmarshal'; import { M } from '@agoric/store'; import { makeLiveSlots } from '../src/liveslots.js'; import { parseVatSlot } from '../src/parseVatSlots.js'; -import { kser } from './kmarshal.js'; import { buildSyscall } from './liveslots-helpers.js'; import { makeStartVat } from './util.js'; import { makeMockGC } from './mock-gc.js'; diff --git a/packages/swingset-liveslots/test/test-dropped-collection-weakrefs.js b/packages/swingset-liveslots/test/test-dropped-collection-weakrefs.js index 466f5476399..8c197fc79ea 100644 --- a/packages/swingset-liveslots/test/test-dropped-collection-weakrefs.js +++ b/packages/swingset-liveslots/test/test-dropped-collection-weakrefs.js @@ -1,7 +1,7 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser } from '@agoric/kmarshal'; import { makeLiveSlots } from '../src/liveslots.js'; -import { kser } from './kmarshal.js'; import { buildSyscall } from './liveslots-helpers.js'; import { makeStartVat } from './util.js'; import { makeMockGC } from './mock-gc.js'; diff --git a/packages/swingset-liveslots/test/test-gc-sensitivity.js b/packages/swingset-liveslots/test/test-gc-sensitivity.js index 86215af4d2e..4952446c911 100644 --- a/packages/swingset-liveslots/test/test-gc-sensitivity.js +++ b/packages/swingset-liveslots/test/test-gc-sensitivity.js @@ -1,9 +1,9 @@ // @ts-nocheck import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser } from '@agoric/kmarshal'; import { buildSyscall } from './liveslots-helpers.js'; import { makeLiveSlots } from '../src/liveslots.js'; -import { kser } from './kmarshal.js'; import { makeMockGC } from './mock-gc.js'; import { makeMessage, makeStartVat } from './util.js'; diff --git a/packages/swingset-liveslots/test/test-handled-promises.js b/packages/swingset-liveslots/test/test-handled-promises.js index fc14cfae634..e13c0055cae 100644 --- a/packages/swingset-liveslots/test/test-handled-promises.js +++ b/packages/swingset-liveslots/test/test-handled-promises.js @@ -7,7 +7,7 @@ import { makePromiseKit } from '@endo/promise-kit'; // Disabled to avoid circular dependencies. // import { makeStoreUtils } from '@agoric/vat-data/src/vat-data-bindings.js'; // import { makeExoUtils } from '@agoric/vat-data/src/exo-utils.js'; -import { kslot, kser } from './kmarshal.js'; +import { kslot, kser } from '@agoric/kmarshal'; import { setupTestLiveslots } from './liveslots-helpers.js'; import { makeResolve, makeReject } from './util.js'; diff --git a/packages/swingset-liveslots/test/test-initial-vrefs.js b/packages/swingset-liveslots/test/test-initial-vrefs.js index 65916a3d06b..c53262d95ad 100644 --- a/packages/swingset-liveslots/test/test-initial-vrefs.js +++ b/packages/swingset-liveslots/test/test-initial-vrefs.js @@ -1,9 +1,9 @@ import test from 'ava'; import { Far } from '@endo/far'; +import { kunser } from '@agoric/kmarshal'; import { M } from '@agoric/store'; import { setupTestLiveslots } from './liveslots-helpers.js'; -import { kunser } from './kmarshal.js'; function buildRootObject(vatPowers, vatParameters, baggage) { const vd = vatPowers.VatData; diff --git a/packages/swingset-liveslots/test/test-liveslots-mock-gc.js b/packages/swingset-liveslots/test/test-liveslots-mock-gc.js index ad73d7d4dfd..d7cff5d0967 100644 --- a/packages/swingset-liveslots/test/test-liveslots-mock-gc.js +++ b/packages/swingset-liveslots/test/test-liveslots-mock-gc.js @@ -2,9 +2,9 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kslot, kser } from '@agoric/kmarshal'; import { makeLiveSlots } from '../src/liveslots.js'; import { parseVatSlot } from '../src/parseVatSlots.js'; -import { kslot, kser } from './kmarshal.js'; import { buildSyscall } from './liveslots-helpers.js'; import { makeMessage, diff --git a/packages/swingset-liveslots/test/test-liveslots-real-gc.js b/packages/swingset-liveslots/test/test-liveslots-real-gc.js index 0bb1c92389e..97cbf33ce1d 100644 --- a/packages/swingset-liveslots/test/test-liveslots-real-gc.js +++ b/packages/swingset-liveslots/test/test-liveslots-real-gc.js @@ -4,9 +4,9 @@ import test from 'ava'; import { Far } from '@endo/marshal'; import { makePromiseKit } from '@endo/promise-kit'; +import { kslot, kser } from '@agoric/kmarshal'; import engineGC from './engine-gc.js'; import { makeGcAndFinalize } from './gc-and-finalize.js'; -import { kslot, kser } from './kmarshal.js'; import { buildSyscall, makeDispatch } from './liveslots-helpers.js'; import { makeMessage, diff --git a/packages/swingset-liveslots/test/test-liveslots.js b/packages/swingset-liveslots/test/test-liveslots.js index 9bcb2fa9ae8..d926212eb86 100644 --- a/packages/swingset-liveslots/test/test-liveslots.js +++ b/packages/swingset-liveslots/test/test-liveslots.js @@ -5,9 +5,9 @@ import { E } from '@endo/eventual-send'; import { Far } from '@endo/marshal'; import { makePromiseKit } from '@endo/promise-kit'; import { Fail } from '@agoric/assert'; +import { kslot, kser, kunser } from '@agoric/kmarshal'; import { M } from '@agoric/store'; import { makeLiveSlots, makeMarshaller } from '../src/liveslots.js'; -import { kslot, kser, kunser } from './kmarshal.js'; import { buildSyscall, makeDispatch } from './liveslots-helpers.js'; import { makeMessage, makeStartVat, makeResolve, makeReject } from './util.js'; import { makeMockGC } from './mock-gc.js'; diff --git a/packages/swingset-liveslots/test/test-vpid-liveslots.js b/packages/swingset-liveslots/test/test-vpid-liveslots.js index 2903c6bded5..0079e8c6a72 100644 --- a/packages/swingset-liveslots/test/test-vpid-liveslots.js +++ b/packages/swingset-liveslots/test/test-vpid-liveslots.js @@ -3,11 +3,11 @@ import test from 'ava'; import { E } from '@endo/eventual-send'; import { makePromiseKit } from '@endo/promise-kit'; -import { Fail } from '@agoric/assert'; import { Far } from '@endo/marshal'; +import { Fail } from '@agoric/assert'; +import { kser, kslot } from '@agoric/kmarshal'; import { buildSyscall, makeDispatch } from './liveslots-helpers.js'; import { makeMessage, makeResolve, makeReject } from './util.js'; -import { kser, kslot } from './kmarshal.js'; function hush(p) { p.then( diff --git a/packages/swingset-liveslots/test/util.js b/packages/swingset-liveslots/test/util.js index 22af120c7ec..a6f815964cc 100644 --- a/packages/swingset-liveslots/test/util.js +++ b/packages/swingset-liveslots/test/util.js @@ -1,5 +1,5 @@ +import { kser } from '@agoric/kmarshal'; import { vstr } from './vat-util.js'; -import { kser } from './kmarshal.js'; export { vstr }; diff --git a/packages/swingset-liveslots/test/vat-util.js b/packages/swingset-liveslots/test/vat-util.js index d88a807cd5c..112205ab790 100644 --- a/packages/swingset-liveslots/test/vat-util.js +++ b/packages/swingset-liveslots/test/vat-util.js @@ -2,7 +2,7 @@ // modules import { Fail } from '@agoric/assert'; -import { kser, kunser } from './kmarshal.js'; +import { kser, kunser } from '@agoric/kmarshal'; export function extractMessage(vatDeliverObject) { const [type, ...vdoargs] = vatDeliverObject; diff --git a/packages/swingset-liveslots/test/virtual-objects/test-kind-changes.js b/packages/swingset-liveslots/test/virtual-objects/test-kind-changes.js index 82b01ac24f1..7642eb3a43b 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-kind-changes.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-kind-changes.js @@ -1,10 +1,10 @@ // @ts-nocheck import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser } from '@agoric/kmarshal'; import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js'; import { makeLiveSlots } from '../../src/liveslots.js'; import { parseVatSlot } from '../../src/parseVatSlots.js'; -import { kser } from '../kmarshal.js'; import { buildSyscall } from '../liveslots-helpers.js'; import { makeStartVat, makeMessage } from '../util.js'; import { makeMockGC } from '../mock-gc.js'; diff --git a/packages/swingset-liveslots/test/virtual-objects/test-state-shape.js b/packages/swingset-liveslots/test/virtual-objects/test-state-shape.js index c2891cbda8e..7c9257ba1f6 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-state-shape.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-state-shape.js @@ -2,9 +2,9 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { kser, kslot } from '@agoric/kmarshal'; import { M } from '@agoric/store'; import { makeLiveSlots } from '../../src/liveslots.js'; -import { kser, kslot } from '../kmarshal.js'; import { buildSyscall } from '../liveslots-helpers.js'; import { makeStartVat, makeMessage } from '../util.js'; import { makeMockGC } from '../mock-gc.js'; diff --git a/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectGC.js b/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectGC.js index 14f9b3ec592..2adf582af06 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectGC.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectGC.js @@ -2,11 +2,11 @@ import test from 'ava'; import { Far } from '@endo/marshal'; +import { krefOf, kser, kslot } from '@agoric/kmarshal'; import { setupTestLiveslots, findSyscallsByType, } from '../liveslots-helpers.js'; -import { krefOf, kser, kslot } from '../kmarshal.js'; import { parseVatSlot } from '../../src/parseVatSlots.js'; // Legs: diff --git a/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectManager.js b/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectManager.js index 86519f4fad1..859d152bf96 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectManager.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-virtualObjectManager.js @@ -1,12 +1,12 @@ // @ts-nocheck import test from 'ava'; +import { kser, kslot } from '@agoric/kmarshal'; import { makeFakeVirtualObjectManager, makeFakeVirtualStuff, } from '../../tools/fakeVirtualSupport.js'; -import { kser, kslot } from '../kmarshal.js'; import { vstr } from '../util.js'; function initThing(label = 'thing', counter = 0) { diff --git a/packages/swingset-liveslots/test/virtual-objects/test-vo-real-gc.js b/packages/swingset-liveslots/test/virtual-objects/test-vo-real-gc.js index e4eadb938a2..bf7283a7d20 100644 --- a/packages/swingset-liveslots/test/virtual-objects/test-vo-real-gc.js +++ b/packages/swingset-liveslots/test/virtual-objects/test-vo-real-gc.js @@ -3,7 +3,7 @@ import test from 'ava'; import { Far } from '@endo/marshal'; -import { kser, kunser } from '../kmarshal.js'; +import { kser, kunser } from '@agoric/kmarshal'; import { setupTestLiveslots } from '../liveslots-helpers.js'; test('virtual object state writes', async t => { diff --git a/packages/swingset-runner/demo/vatFailure/vat-bad.js b/packages/swingset-runner/demo/vatFailure/vat-bad.js index 7ea8c6e058b..bea73c6da98 100644 --- a/packages/swingset-runner/demo/vatFailure/vat-bad.js +++ b/packages/swingset-runner/demo/vatFailure/vat-bad.js @@ -1,5 +1,5 @@ import { assert } from '@agoric/assert'; -import { kser } from '@agoric/swingset-vat/src/lib/kmarshal.js'; +import { kser } from '@agoric/kmarshal'; export default function setup(syscall, _state, _helpers, _vatPowers) { function deliver(target, method, args) { diff --git a/packages/swingset-runner/package.json b/packages/swingset-runner/package.json index ae68dff2150..304eb4b9631 100644 --- a/packages/swingset-runner/package.json +++ b/packages/swingset-runner/package.json @@ -24,6 +24,7 @@ "@agoric/ertp": "^0.16.2", "@agoric/internal": "^0.3.2", "@agoric/inter-protocol": "^0.16.1", + "@agoric/kmarshal": "^0.1.0", "@agoric/stat-logger": "^0.4.28", "@agoric/store": "^0.9.2", "@agoric/swing-store": "^0.9.1", diff --git a/packages/zoe/package.json b/packages/zoe/package.json index db86ba96d19..343581b73ef 100644 --- a/packages/zoe/package.json +++ b/packages/zoe/package.json @@ -65,6 +65,7 @@ }, "devDependencies": { "@endo/init": "^0.5.59", + "@agoric/kmarshal": "^0.1.0", "ava": "^5.3.0", "c8": "^7.13.0", "import-meta-resolve": "^2.2.1", diff --git a/packages/zoe/test/swingsetTests/zoe/test-zoe-upgrade.js b/packages/zoe/test/swingsetTests/zoe/test-zoe-upgrade.js index 0acd57b2a22..226a2d1450a 100644 --- a/packages/zoe/test/swingsetTests/zoe/test-zoe-upgrade.js +++ b/packages/zoe/test/swingsetTests/zoe/test-zoe-upgrade.js @@ -1,7 +1,7 @@ import '@agoric/swingset-liveslots/tools/prepare-test-env.js'; import test from 'ava'; import { buildVatController } from '@agoric/swingset-vat'; -import { kunser } from '@agoric/swingset-vat/src/lib/kmarshal.js'; +import { kunser } from '@agoric/kmarshal'; const bfile = name => new URL(name, import.meta.url).pathname;