-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add globalThis.VatData.passStyleOf to liveslots-hosted vat environment #9431
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b337eef
fix: add passStyleOf to VatData global
erights 2ace6d9
add globalThis.VatData.passStyleOf to liveslots-hosted vat environment
warner f262d8c
use symbol-named property instead of globalThis.passStyleOf
warner 978a59e
change liveslots to provide passStyleOf on a symbol-named property
warner 9f0d4b8
move harden() back to original spot
warner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection to doing the
harden
here. But curious about your motivation for moving it? There's no mutation between the initialization and the harden, so the more traditional harden around the object literal should still be equivalent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why I moved it.. I'll move it back.