-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use symbol-named property instead of globalThis.passStyleOf
Update the swingset test to look for it there, and compare against a bundle-generated version (they should be different). This currently fails because importBundle() does not respect symbol-named properties of `vatGlobals`. Restored the SwingSet/package.json dependency on `@endo/pass-style` so the vat-under-test can get a bundle-generated version, for comparison. Added a liveslots-local test of the same, which passes because it's only looking at the `vatGlobals` given to `buildVatNamespace()`, and doesn't use `importBundle()`.
- Loading branch information
Showing
5 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import '@endo/init/debug.js'; | ||
import test from 'ava'; | ||
import { Far } from '@endo/marshal'; | ||
import { kser } from '@agoric/kmarshal'; | ||
import { passStyleOf } from '@endo/pass-style'; | ||
import { PassStyleOfEndowmentSymbol } from '@endo/pass-style/endow.js'; | ||
import { makeLiveSlots } from '../src/index.js'; | ||
import { makeStartVat } from './util.js'; | ||
import { buildSyscall } from './liveslots-helpers.js'; | ||
import { makeMockGC } from './mock-gc.js'; | ||
|
||
test('vat globals', async t => { | ||
const { syscall } = buildSyscall(); | ||
const gcTools = makeMockGC(); | ||
const buildRootObject = () => Far('root', {}); | ||
let called = 0; | ||
let vatGlobals; | ||
let inescapableGlobalProperties; | ||
const vatNS = harden({ buildRootObject }); | ||
// buildVatNamespace | ||
const bVN = async (vG, iGP) => { | ||
called += 1; | ||
vatGlobals = vG; | ||
inescapableGlobalProperties = iGP; | ||
return vatNS; | ||
}; | ||
|
||
const ls = makeLiveSlots(syscall, 'vatA', {}, {}, gcTools, undefined, bVN); | ||
t.is(called, 0); // not called yet | ||
await ls.dispatch(makeStartVat(kser())); | ||
t.is(called, 1); | ||
t.truthy(vatGlobals); | ||
|
||
// 'harden' is provided by SES (installed by the supervisor), not liveslots | ||
t.is(typeof vatGlobals.harden, 'undefined'); | ||
|
||
// but liveslots provides VatData | ||
t.is(typeof vatGlobals.VatData, 'object'); | ||
t.is(typeof vatGlobals.VatData, 'object'); | ||
t.is(typeof vatGlobals.VatData.defineKind, 'function'); | ||
t.is(typeof vatGlobals.VatData.defineKindMulti, 'function'); | ||
t.is(typeof vatGlobals.VatData.defineDurableKind, 'function'); | ||
t.is(typeof vatGlobals.VatData.defineDurableKindMulti, 'function'); | ||
t.is(typeof vatGlobals.VatData.makeKindHandle, 'function'); | ||
t.is(typeof vatGlobals.VatData.canBeDurable, 'function'); | ||
t.is(typeof vatGlobals.VatData.providePromiseWatcher, 'function'); | ||
t.is(typeof vatGlobals.VatData.watchPromise, 'function'); | ||
t.is(typeof vatGlobals.VatData.makeScalarBigMapStore, 'function'); | ||
t.is(typeof vatGlobals.VatData.makeScalarBigWeakMapStore, 'function'); | ||
t.is(typeof vatGlobals.VatData.makeScalarBigSetStore, 'function'); | ||
t.is(typeof vatGlobals.VatData.makeScalarBigWeakSetStore, 'function'); | ||
t.is(typeof vatGlobals[PassStyleOfEndowmentSymbol], 'function'); | ||
// this is the passStyleOf created by liveslots, with a real WeakMap | ||
t.is(vatGlobals[PassStyleOfEndowmentSymbol], passStyleOf); | ||
|
||
t.is(typeof inescapableGlobalProperties.WeakMap, 'function'); | ||
t.not(inescapableGlobalProperties.WeakMap, WeakMap); | ||
t.is(typeof inescapableGlobalProperties.WeakSet, 'function'); | ||
t.not(inescapableGlobalProperties.WeakSet, WeakSet); | ||
}); |