move prepare-test-env-ava helper to a separate package? #6703
Labels
enhancement
New feature or request
SwingSet
package: SwingSet
test
tooling
repo-wide infrastructure
vaults_triage
DO NOT USE
What is the Problem Being Solved?
#6561 (comment) is a discussion/lament that a package like
swing-store
, which wants to run unit tests (using both AVA and SES), needs to import a helper tool:which is exported by SwingSet, but at the same time SwingSet is importing libraries from
swing-store
. This isn't exactly a circular dependency, becauseprepare-test-env-ava.js
is only used for unit tests, soswing-store
has adevDependencies:
pointing at SwingSet, whereas SwingSet has a fulldependencies:
pointing at swing-store. But it's still annoying.Most of our code uses
harden
, which is provided as a global when you prepare a SES environment. The easiest way to do this is withimport '@endo/init.js'
. For unit tests, we frequently want a different set of tradeoffs ("sacrificing safety to optimize for debugging and testing", asSwingSet/tools/install-ses-debug.js
says), for whichimport '@endo/init/debug.js'
is the way to go.Many of our unit tests could do:
except(?) AVA has some incompatibilities with SES (maybe changes to Error objects or stack traces?). We have code that works around these in
@endo/ses-ava/exported.js
. The@agoric/swingset-vat/prepare-test-env-ava.js
tool does the following to prepare this:A subset of our code also uses "VatData", which includes things like
defineKind
andmakeScalarBigMapStore
. This includes both libraries that use it (e.g. ERTP), and other code or libraries that don't use it directly but import from those libraries.The core VatData utilities are added to a vat environment by SwingSet (specifically liveslots), as
globalThis.VatData
. This is wrapped by the@agoric/vat-data
package, so userspace code (libraries which need virtual/durable objects, or collections) can doimport { defineKind } from '@agoric/vat-data'
. But the Compartment in which this is run must either be created by liveslots (running under a real kernel), or it must be set up specially with "fake virtual stuff".The
@agoric/swingset-vat/tools/prepare-test-env-ava
also importsprepare-test-env.js
, which assembles the cadre of "fake virtual stuff" to support the use ofglobalThis.VatData
outside of a real (liveslots-hosted) vat environment. The tricky part is thatThe Problem
We have an awkward split between SwingSet (which defines the kernel, including the liveslots layer that hosts vats), the VatData package (which is imported by userspace, but relies upon a global populated by liveslots), SES (
@endo/init
), and the tooling necessary to run our unit-test framework of choice (AVA).SwingSet should not really be hosting AVA-specific tools: swingset uses AVA for its own unit tests, like everything in
agoric-sdk
, but it doesn't need AVA to run a kernel. And this tool is accessed through a deep import (@agoric/swingset-vat/tools/prepare-test-env-ava.js
), which is evil and causes too much coupling between packages (Swingset can't rearrange its internal directory structure without breaking downstream importers).Description of the Design
I'm not sure yet, but I'm thinking that these tools should move out to their own package(s).
We might make one package specifically for using both AVA and SES at the same time. This would really want to live in the Endo repo. It would need to do the
wrapTest()
dance listed above.We might make a second package specifically for using AVA, SES, and VatData at the same time. This would want to live in agoric-sdk, but not in
packages/SwingSet/
. It needs access to the liveslots tools (virtualObjectManager.js
,virtualReferences.js
,watchedPromises.js
), which normally live inpackages/SwingSet/src/liveslots/
, but which will probably move to their own package as part of the #6596 effort (we should consider the needs of this tool when we design the exports of the new liveslots package).Security Considerations
Probably none, this all affects unit tests and packaging, not runtime authorities.
Test Plan
The text was updated successfully, but these errors were encountered: