-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7891 from Agoric/mfig-zone-make-once
feat(zone)!: implement `zone.makeOnce(key, maker)`
- Loading branch information
Showing
29 changed files
with
732 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,14 @@ | ||
/* global globalThis */ | ||
/** | ||
* Prepare Agoric SwingSet vat global environment for testing. | ||
* | ||
* Installs Hardened JS (and does lockdown), plus adds mocks for virtual objects | ||
* and stores. | ||
*/ | ||
|
||
import '@endo/init/pre-bundle-source.js'; | ||
import '@endo/init/pre.js'; | ||
|
||
import './install-ses-debug.js'; | ||
import { makeFakeVirtualStuff } from '@agoric/swingset-liveslots/tools/fakeVirtualSupport.js'; | ||
import { reincarnate } from './setup-vat-data.js'; | ||
|
||
const { vom, cm, wpm } = makeFakeVirtualStuff(); | ||
|
||
const { | ||
defineKind, | ||
defineKindMulti, | ||
defineDurableKind, | ||
defineDurableKindMulti, | ||
makeKindHandle, | ||
canBeDurable, | ||
} = vom; | ||
|
||
const { | ||
makeScalarBigMapStore, | ||
makeScalarBigWeakMapStore, | ||
makeScalarBigSetStore, | ||
makeScalarBigWeakSetStore, | ||
} = cm; | ||
|
||
const { watchPromise, providePromiseWatcher } = wpm; | ||
|
||
const VatData = harden({ | ||
defineKind, | ||
defineKindMulti, | ||
defineDurableKind, | ||
defineDurableKindMulti, | ||
makeKindHandle, | ||
providePromiseWatcher, | ||
watchPromise, | ||
makeScalarBigMapStore, | ||
makeScalarBigWeakMapStore, | ||
makeScalarBigSetStore, | ||
makeScalarBigWeakSetStore, | ||
canBeDurable, | ||
}); | ||
|
||
globalThis.VatData = VatData; | ||
// Install the VatData globals. | ||
reincarnate(); |
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,54 @@ | ||
// @ts-check | ||
/* global globalThis */ | ||
// This file produces the globalThis.VatData property outside of a running | ||
// SwingSet so that it can be used by '@agoric/vat-data' (which only *consumes* | ||
// `globalThis.VatData`) in code under test. | ||
import { makeFakeVirtualStuff } from '@agoric/swingset-liveslots/tools/fakeVirtualSupport.js'; | ||
|
||
const { WeakMap, WeakSet } = globalThis; | ||
|
||
/** @type {ReturnType<makeFakeVirtualStuff>} */ | ||
let fakeVomKit; | ||
|
||
globalThis.VatData = harden({ | ||
defineKind: (...args) => fakeVomKit.vom.defineKind(...args), | ||
defineKindMulti: (...args) => fakeVomKit.vom.defineKindMulti(...args), | ||
defineDurableKind: (...args) => fakeVomKit.vom.defineDurableKind(...args), | ||
defineDurableKindMulti: (...args) => | ||
fakeVomKit.vom.defineDurableKindMulti(...args), | ||
makeKindHandle: (...args) => fakeVomKit.vom.makeKindHandle(...args), | ||
canBeDurable: (...args) => fakeVomKit.vom.canBeDurable(...args), | ||
providePromiseWatcher: (...args) => | ||
fakeVomKit.wpm.providePromiseWatcher(...args), | ||
watchPromise: (...args) => fakeVomKit.wpm.watchPromise(...args), | ||
makeScalarBigMapStore: (...args) => | ||
fakeVomKit.cm.makeScalarBigMapStore(...args), | ||
makeScalarBigWeakMapStore: (...args) => | ||
fakeVomKit.cm.makeScalarBigWeakMapStore(...args), | ||
makeScalarBigSetStore: (...args) => | ||
fakeVomKit.cm.makeScalarBigSetStore(...args), | ||
makeScalarBigWeakSetStore: (...args) => | ||
fakeVomKit.cm.makeScalarBigWeakSetStore(...args), | ||
}); | ||
|
||
export const reincarnate = (options = {}) => { | ||
const { fakeStore = new Map(), fakeVomKit: fvk } = options; | ||
|
||
if (options.fakeVomKit) { | ||
fvk.vom.flushStateCache(); | ||
fvk.cm.flushSchemaCache(); | ||
fvk.vrm.flushIDCounters(); | ||
} | ||
|
||
fakeVomKit = makeFakeVirtualStuff({ | ||
...options, | ||
fakeStore, | ||
WeakMap, | ||
WeakSet, | ||
}); | ||
|
||
globalThis.WeakMap = fakeVomKit.vom.VirtualObjectAwareWeakMap; | ||
globalThis.WeakSet = fakeVomKit.vom.VirtualObjectAwareWeakSet; | ||
|
||
return { ...options, fakeStore, fakeVomKit }; | ||
}; |
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
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.