@agoric/zone 0.2.3-dev-eb7e9eb.0 → 0.2.3-u11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +4 -4
- package/heap.js +1 -1
- package/jsconfig.json +19 -0
- package/package.json +8 -16
- package/src/durable.js +16 -49
- package/src/heap.js +42 -0
- package/src/index.js +36 -3
- package/src/virtual.js +15 -39
- package/durable.d.ts +0 -2
- package/durable.d.ts.map +0 -1
- package/heap.d.ts +0 -2
- package/heap.d.ts.map +0 -1
- package/src/durable.d.ts +0 -2
- package/src/durable.d.ts.map +0 -1
- package/src/exports.d.ts +0 -8
- package/src/exports.js +0 -2
- package/src/index.d.ts +0 -3
- package/src/index.d.ts.map +0 -1
- package/src/virtual.d.ts +0 -2
- package/src/virtual.d.ts.map +0 -1
- package/test/prepare-test-env-ava.js +0 -21
- package/test/test-exos.js +0 -126
- package/test/test-make-once.js +0 -66
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -13
- package/virtual.d.ts +0 -2
- package/virtual.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.2.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/zone@0.2.2...@agoric/zone@0.2.3-u11.0) (2023-08-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @agoric/zone
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
### [0.2.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/zone@0.2.1...@agoric/zone@0.2.2) (2023-06-02)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @agoric/zone
|
package/README.md
CHANGED
|
@@ -12,18 +12,18 @@ An example of making a Zone-aware vat might look something like this:
|
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
14
|
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { zoneFrobulator } from 'frob-package';
|
|
16
|
+
import { zoneWidget } from 'widget-package';
|
|
17
17
|
|
|
18
18
|
export const buildRootObject = (vatPowers, _args, baggage) => {
|
|
19
19
|
const zone = makeDurableZone(baggage);
|
|
20
20
|
|
|
21
21
|
// Ensure that Widgets cannot interfere with Frobs.
|
|
22
|
-
const makeWidget =
|
|
22
|
+
const makeWidget = zoneWidget(zone.subZone('Widgets'));
|
|
23
23
|
|
|
24
24
|
// Create a collection of frobulators.
|
|
25
25
|
const frobZone = zone.subZone('Frobs');
|
|
26
|
-
const makeFrobulator =
|
|
26
|
+
const makeFrobulator = zoneFrobulator(frobZone);
|
|
27
27
|
const widgetToFrob = frobZone.mapStore('widgetToFrob');
|
|
28
28
|
|
|
29
29
|
return Far('WidgetFrobulator', {
|
package/heap.js
CHANGED
package/jsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// This file can contain .js-specific Typescript compiler config.
|
|
2
|
+
{
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"checkJs": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"downlevelIteration": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"*.js",
|
|
15
|
+
"scripts",
|
|
16
|
+
"src",
|
|
17
|
+
"test",
|
|
18
|
+
],
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/zone",
|
|
3
|
-
"version": "0.2.3-
|
|
3
|
+
"version": "0.2.3-u11.0",
|
|
4
4
|
"description": "Allocation zone abstraction for objects on the heap, persistent stores, etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
7
7
|
"main": "./src/index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"test": "ava",
|
|
13
|
-
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
|
|
10
|
+
"test": "true || ava",
|
|
11
|
+
"test:c8": "true || c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
|
|
14
12
|
"test:xs": "exit 0",
|
|
15
13
|
"lint-fix": "yarn lint:eslint --fix",
|
|
16
14
|
"lint": "run-s --continue-on-error lint:*",
|
|
17
|
-
"lint:types": "tsc",
|
|
15
|
+
"lint:types": "tsc -p jsconfig.json",
|
|
18
16
|
"lint:eslint": "eslint ."
|
|
19
17
|
},
|
|
20
18
|
"exports": {
|
|
@@ -27,15 +25,9 @@
|
|
|
27
25
|
"author": "Agoric",
|
|
28
26
|
"license": "Apache-2.0",
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@agoric/
|
|
31
|
-
"@agoric/vat-data": "0.5.3-
|
|
32
|
-
"@endo/far": "^0.2.
|
|
33
|
-
"@endo/pass-style": "^0.1.4"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-eb7e9eb.0+eb7e9eb",
|
|
37
|
-
"@endo/patterns": "^0.2.3",
|
|
38
|
-
"ava": "^5.3.0"
|
|
28
|
+
"@agoric/store": "^0.9.3-u11.0",
|
|
29
|
+
"@agoric/vat-data": "^0.5.3-u11.0",
|
|
30
|
+
"@endo/far": "^0.2.18"
|
|
39
31
|
},
|
|
40
32
|
"publishConfig": {
|
|
41
33
|
"access": "public"
|
|
@@ -50,5 +42,5 @@
|
|
|
50
42
|
"timeout": "20m",
|
|
51
43
|
"workerThreads": false
|
|
52
44
|
},
|
|
53
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "92b6cd72484079b0349d8ccfa4510aeb820e8d67"
|
|
54
46
|
}
|
package/src/durable.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
// @jessie-check
|
|
3
2
|
|
|
4
|
-
import { Far } from '@endo/far';
|
|
5
3
|
import {
|
|
6
4
|
canBeDurable,
|
|
7
5
|
makeScalarMapStore,
|
|
@@ -12,35 +10,20 @@ import {
|
|
|
12
10
|
provideDurableSetStore,
|
|
13
11
|
provideDurableWeakMapStore,
|
|
14
12
|
provideDurableWeakSetStore,
|
|
13
|
+
M,
|
|
15
14
|
} from '@agoric/vat-data';
|
|
16
15
|
|
|
17
|
-
import {
|
|
18
|
-
agoricVatDataKeys as keys,
|
|
19
|
-
isPassable,
|
|
20
|
-
makeOnceKit,
|
|
21
|
-
} from '@agoric/base-zone';
|
|
16
|
+
import { Far } from '@endo/far';
|
|
22
17
|
|
|
23
18
|
const { Fail } = assert;
|
|
24
19
|
|
|
25
|
-
/**
|
|
26
|
-
* A variant of `canBeDurable` that returns `false` instead of ever throwing.
|
|
27
|
-
*
|
|
28
|
-
* @param {unknown} specimen
|
|
29
|
-
* @returns {boolean}
|
|
30
|
-
*/
|
|
31
|
-
const isStorable = specimen => isPassable(specimen) && canBeDurable(specimen);
|
|
32
|
-
harden(isStorable);
|
|
33
|
-
|
|
34
20
|
/**
|
|
35
21
|
* @param {() => import('@agoric/vat-data').Baggage} getBaggage
|
|
36
22
|
*/
|
|
37
23
|
const attachDurableStores = getBaggage => {
|
|
38
24
|
/** @type {import('.').Zone['mapStore']} */
|
|
39
|
-
const mapStore = (label, options) =>
|
|
40
|
-
|
|
41
|
-
const ret = provideDurableMapStore(baggage, label, options);
|
|
42
|
-
return ret;
|
|
43
|
-
};
|
|
25
|
+
const mapStore = (label, options) =>
|
|
26
|
+
provideDurableMapStore(getBaggage(), label, options);
|
|
44
27
|
/** @type {import('.').Zone['setStore']} */
|
|
45
28
|
const setStore = (label, options) =>
|
|
46
29
|
provideDurableSetStore(getBaggage(), label, options);
|
|
@@ -55,7 +38,7 @@ const attachDurableStores = getBaggage => {
|
|
|
55
38
|
return Far('durableStores', {
|
|
56
39
|
// eslint-disable-next-line no-use-before-define
|
|
57
40
|
detached: () => detachedDurableStores,
|
|
58
|
-
isStorable,
|
|
41
|
+
isStorable: canBeDurable,
|
|
59
42
|
mapStore,
|
|
60
43
|
setStore,
|
|
61
44
|
weakMapStore,
|
|
@@ -64,7 +47,7 @@ const attachDurableStores = getBaggage => {
|
|
|
64
47
|
};
|
|
65
48
|
|
|
66
49
|
/** @type {import('.').Stores} */
|
|
67
|
-
const detachedDurableStores = attachDurableStores(() =>
|
|
50
|
+
export const detachedDurableStores = attachDurableStores(() =>
|
|
68
51
|
makeScalarMapStore('detached'),
|
|
69
52
|
);
|
|
70
53
|
|
|
@@ -72,20 +55,10 @@ const detachedDurableStores = attachDurableStores(() =>
|
|
|
72
55
|
* Create a zone whose objects persist between Agoric vat upgrades.
|
|
73
56
|
*
|
|
74
57
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
75
|
-
* @param {string} [baseLabel]
|
|
76
58
|
* @returns {import('.').Zone}
|
|
77
59
|
*/
|
|
78
|
-
export const makeDurableZone =
|
|
60
|
+
export const makeDurableZone = baggage => {
|
|
79
61
|
baggage || Fail`baggage required`;
|
|
80
|
-
|
|
81
|
-
const attachedStores = attachDurableStores(() => baggage);
|
|
82
|
-
|
|
83
|
-
const { makeOnce, wrapProvider } = makeOnceKit(
|
|
84
|
-
baseLabel,
|
|
85
|
-
attachedStores,
|
|
86
|
-
baggage,
|
|
87
|
-
);
|
|
88
|
-
|
|
89
62
|
/** @type {import('.').Zone['exoClass']} */
|
|
90
63
|
const exoClass = (...args) => prepareExoClass(baggage, ...args);
|
|
91
64
|
/** @type {import('.').Zone['exoClassKit']} */
|
|
@@ -93,28 +66,22 @@ export const makeDurableZone = (baggage, baseLabel = 'durableZone') => {
|
|
|
93
66
|
/** @type {import('.').Zone['exo']} */
|
|
94
67
|
const exo = (...args) => prepareExo(baggage, ...args);
|
|
95
68
|
|
|
96
|
-
const
|
|
69
|
+
const attachedStores = attachDurableStores(() => baggage);
|
|
97
70
|
|
|
98
71
|
/** @type {import('.').Zone['subZone']} */
|
|
99
72
|
const subZone = (label, options = {}) => {
|
|
100
|
-
const subBaggage =
|
|
101
|
-
return makeDurableZone(subBaggage
|
|
73
|
+
const subBaggage = provideDurableMapStore(baggage, label, options);
|
|
74
|
+
return makeDurableZone(subBaggage);
|
|
102
75
|
};
|
|
103
76
|
|
|
104
77
|
return Far('durableZone', {
|
|
105
|
-
exo
|
|
106
|
-
exoClass
|
|
107
|
-
exoClassKit
|
|
78
|
+
exo,
|
|
79
|
+
exoClass,
|
|
80
|
+
exoClassKit,
|
|
108
81
|
subZone,
|
|
109
|
-
|
|
110
|
-
makeOnce,
|
|
111
|
-
detached: attachedStores.detached,
|
|
112
|
-
isStorable: attachedStores.isStorable,
|
|
113
|
-
|
|
114
|
-
mapStore: wrapProvider(attachedStores.mapStore, keys.store),
|
|
115
|
-
setStore: wrapProvider(attachedStores.setStore, keys.store),
|
|
116
|
-
weakMapStore: wrapProvider(attachedStores.weakMapStore, keys.store),
|
|
117
|
-
weakSetStore: wrapProvider(attachedStores.weakSetStore, keys.store),
|
|
82
|
+
...attachedStores,
|
|
118
83
|
});
|
|
119
84
|
};
|
|
120
85
|
harden(makeDurableZone);
|
|
86
|
+
|
|
87
|
+
export { M };
|
package/src/heap.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @jessie-check
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
makeExo,
|
|
5
|
+
defineExoClass,
|
|
6
|
+
defineExoClassKit,
|
|
7
|
+
makeScalarMapStore,
|
|
8
|
+
makeScalarSetStore,
|
|
9
|
+
makeScalarWeakMapStore,
|
|
10
|
+
makeScalarWeakSetStore,
|
|
11
|
+
M,
|
|
12
|
+
} from '@agoric/store';
|
|
13
|
+
|
|
14
|
+
import { Far } from '@endo/far';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {import('.').Stores}
|
|
18
|
+
*/
|
|
19
|
+
const heapStores = Far('heapStores', {
|
|
20
|
+
detached: () => heapStores,
|
|
21
|
+
isStorable: _specimen => true,
|
|
22
|
+
|
|
23
|
+
setStore: makeScalarSetStore,
|
|
24
|
+
mapStore: makeScalarMapStore,
|
|
25
|
+
weakMapStore: makeScalarWeakMapStore,
|
|
26
|
+
weakSetStore: makeScalarWeakSetStore,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A heap (in-memory) zone that uses the default exo and store implementations.
|
|
31
|
+
*
|
|
32
|
+
* @type {import('.').Zone}
|
|
33
|
+
*/
|
|
34
|
+
export const heapZone = Far('heapZone', {
|
|
35
|
+
exoClass: defineExoClass,
|
|
36
|
+
exoClassKit: defineExoClassKit,
|
|
37
|
+
exo: makeExo,
|
|
38
|
+
subZone: (_label, _options) => heapZone,
|
|
39
|
+
...heapStores,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export { M };
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// @jessie-check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { makeExo, defineExoClass, defineExoClassKit } from '@agoric/store';
|
|
4
|
+
|
|
5
|
+
export * from './heap.js';
|
|
6
|
+
|
|
7
|
+
// References to allow the below typeofs to succeed.
|
|
8
|
+
makeExo;
|
|
9
|
+
defineExoClass;
|
|
10
|
+
defineExoClassKit;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {ExoZone & Stores} Zone A bag of methods for creating defensible objects and
|
|
14
|
+
* collections with the same allocation semantics (ephemeral, persistent, etc)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} ExoZone
|
|
19
|
+
* @property {typeof makeExo} exo create a singleton exo-object instance bound to this zone
|
|
20
|
+
* @property {typeof defineExoClass} exoClass create a maker function that can be used to create exo-objects bound to this zone
|
|
21
|
+
* @property {typeof defineExoClassKit} exoClassKit create a "kit" maker function that can be used to create a record of exo-objects sharing the same state
|
|
22
|
+
* @property {(label: string, options?: StoreOptions) => Zone} subZone create a new Zone that can be passed to untrusted consumers without exposing the storage of the parent zone
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {object} Stores
|
|
27
|
+
* @property {() => Stores} detached obtain store providers which are detached (the stores are anonymous rather than bound to `label` in the zone)
|
|
28
|
+
* @property {(specimen: unknown) => boolean} isStorable return true if the specimen can be stored in the zone, whether as exo-object state or in a store
|
|
29
|
+
* @property {<K,V>(label: string, options?: StoreOptions) => MapStore<K, V>} mapStore provide a Map-like store named `label` in the zone
|
|
30
|
+
* @property {<K>(label: string, options?: StoreOptions) => SetStore<K>} setStore provide a Set-like store named `label` in the zone
|
|
31
|
+
* @property {<K,V>(
|
|
32
|
+
* label: string, options?: StoreOptions) => WeakMapStore<K, V>
|
|
33
|
+
* } weakMapStore provide a WeakMap-like store named `label` in the zone
|
|
34
|
+
* @property {<K>(
|
|
35
|
+
* label: string, options?: StoreOptions) => WeakSetStore<K>
|
|
36
|
+
* } weakSetStore provide a WeakSet-like store named `label` in the zone
|
|
37
|
+
*/
|
package/src/virtual.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
// @jessie-check
|
|
3
2
|
|
|
4
|
-
import { Far } from '@endo/far';
|
|
5
3
|
import {
|
|
4
|
+
canBeDurable,
|
|
6
5
|
defineVirtualExoClass,
|
|
7
6
|
defineVirtualExoClassKit,
|
|
8
7
|
makeScalarBigMapStore,
|
|
9
8
|
makeScalarBigSetStore,
|
|
10
9
|
makeScalarBigWeakMapStore,
|
|
11
10
|
makeScalarBigWeakSetStore,
|
|
11
|
+
M,
|
|
12
12
|
} from '@agoric/vat-data';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
agoricVatDataKeys as keys,
|
|
16
|
-
isPassable,
|
|
17
|
-
makeOnceKit,
|
|
18
|
-
} from '@agoric/base-zone';
|
|
14
|
+
import { Far } from '@endo/far';
|
|
19
15
|
|
|
20
16
|
const emptyRecord = harden({});
|
|
21
17
|
const initEmpty = harden(() => emptyRecord);
|
|
@@ -26,7 +22,7 @@ const initEmpty = harden(() => emptyRecord);
|
|
|
26
22
|
*
|
|
27
23
|
* @type {import('.').Zone['exo']}
|
|
28
24
|
*/
|
|
29
|
-
const
|
|
25
|
+
const defineVirtualExo = (
|
|
30
26
|
label,
|
|
31
27
|
interfaceGuard,
|
|
32
28
|
methods,
|
|
@@ -47,9 +43,9 @@ const makeVirtualExo = (
|
|
|
47
43
|
};
|
|
48
44
|
|
|
49
45
|
/** @type {import('.').Stores} */
|
|
50
|
-
const detachedVirtualStores = Far('virtualStores', {
|
|
46
|
+
export const detachedVirtualStores = Far('virtualStores', {
|
|
51
47
|
detached: () => detachedVirtualStores,
|
|
52
|
-
isStorable:
|
|
48
|
+
isStorable: canBeDurable,
|
|
53
49
|
mapStore: makeScalarBigMapStore,
|
|
54
50
|
setStore: makeScalarBigSetStore,
|
|
55
51
|
weakMapStore: makeScalarBigWeakMapStore,
|
|
@@ -60,35 +56,15 @@ const detachedVirtualStores = Far('virtualStores', {
|
|
|
60
56
|
* A zone that utilizes external storage to reduce the memory footprint of the
|
|
61
57
|
* current vat.
|
|
62
58
|
*
|
|
63
|
-
* @
|
|
64
|
-
* @returns {import('.').Zone}
|
|
59
|
+
* @type {import('.').Zone}
|
|
65
60
|
*/
|
|
66
|
-
export const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
61
|
+
export const virtualZone = Far('virtualZone', {
|
|
62
|
+
exo: defineVirtualExo,
|
|
63
|
+
exoClass: defineVirtualExoClass,
|
|
64
|
+
exoClassKit: defineVirtualExoClassKit,
|
|
65
|
+
subZone: (_label, _options = {}) => virtualZone,
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* @param {any} _options
|
|
75
|
-
*/
|
|
76
|
-
const makeSubZone = (label, _options) =>
|
|
77
|
-
makeVirtualZone(`${baseLabel}.${label}`);
|
|
78
|
-
|
|
79
|
-
return Far('virtualZone', {
|
|
80
|
-
exo: wrapProvider(makeVirtualExo, keys.exo),
|
|
81
|
-
exoClass: wrapProvider(defineVirtualExoClass, keys.exoClass),
|
|
82
|
-
exoClassKit: wrapProvider(defineVirtualExoClassKit, keys.exoClassKit),
|
|
83
|
-
subZone: wrapProvider(makeSubZone),
|
|
84
|
-
|
|
85
|
-
makeOnce,
|
|
86
|
-
detached: detachedVirtualStores.detached,
|
|
87
|
-
isStorable: detachedVirtualStores.isStorable,
|
|
67
|
+
...detachedVirtualStores,
|
|
68
|
+
});
|
|
88
69
|
|
|
89
|
-
|
|
90
|
-
setStore: wrapProvider(detachedVirtualStores.setStore),
|
|
91
|
-
weakMapStore: wrapProvider(detachedVirtualStores.weakMapStore),
|
|
92
|
-
weakSetStore: wrapProvider(detachedVirtualStores.weakSetStore),
|
|
93
|
-
});
|
|
94
|
-
};
|
|
70
|
+
export { M };
|
package/durable.d.ts
DELETED
package/durable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"durable.d.ts","sourceRoot":"","sources":["durable.js"],"names":[],"mappings":""}
|
package/heap.d.ts
DELETED
package/heap.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heap.d.ts","sourceRoot":"","sources":["heap.js"],"names":[],"mappings":""}
|
package/src/durable.d.ts
DELETED
package/src/durable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"durable.d.ts","sourceRoot":"","sources":["durable.js"],"names":[],"mappings":"AA6EO,yCAJI,OAAO,kBAAkB,EAAE,OAAO,mCAEhC,OAAO,GAAG,EAAE,IAAI,CA2C5B"}
|
package/src/exports.d.ts
DELETED
package/src/exports.js
DELETED
package/src/index.d.ts
DELETED
package/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
package/src/virtual.d.ts
DELETED
package/src/virtual.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["virtual.js"],"names":[],"mappings":"AAiEO,iEAFM,OAAO,GAAG,EAAE,IAAI,CA8B5B"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
|
|
2
|
-
import { reincarnate } from '@agoric/swingset-liveslots/tools/setup-vat-data.js';
|
|
3
|
-
|
|
4
|
-
import test from 'ava';
|
|
5
|
-
|
|
6
|
-
export { test };
|
|
7
|
-
|
|
8
|
-
/** @type {ReturnType<typeof reincarnate>} */
|
|
9
|
-
let incarnation;
|
|
10
|
-
|
|
11
|
-
export const annihilate = () => {
|
|
12
|
-
incarnation = reincarnate({ relaxDurabilityRules: false });
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const getBaggage = () => {
|
|
16
|
-
return incarnation.fakeVomKit.cm.provideBaggage();
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const nextLife = () => {
|
|
20
|
-
incarnation = reincarnate(incarnation);
|
|
21
|
-
};
|
package/test/test-exos.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/order
|
|
2
|
-
import {
|
|
3
|
-
annihilate,
|
|
4
|
-
getBaggage,
|
|
5
|
-
nextLife,
|
|
6
|
-
test,
|
|
7
|
-
} from './prepare-test-env-ava.js';
|
|
8
|
-
|
|
9
|
-
import * as vatData from '@agoric/vat-data';
|
|
10
|
-
|
|
11
|
-
import { agoricVatDataKeys as keys } from '@agoric/base-zone';
|
|
12
|
-
import {
|
|
13
|
-
agoricVatDataCompatibleKeys,
|
|
14
|
-
testFirstZoneIncarnation,
|
|
15
|
-
testSecondZoneIncarnation,
|
|
16
|
-
testGreeter,
|
|
17
|
-
} from '@agoric/base-zone/tools/testers.js';
|
|
18
|
-
import * as g from '@agoric/base-zone/tools/greeter.js';
|
|
19
|
-
|
|
20
|
-
import { makeDurableZone } from '../durable.js';
|
|
21
|
-
import { makeHeapZone } from '../heap.js';
|
|
22
|
-
import { makeVirtualZone } from '../virtual.js';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {import('ava').Assertions} t
|
|
26
|
-
* @param {MapStore} baggage
|
|
27
|
-
*/
|
|
28
|
-
const testFirstVatDataIncarnation = (t, baggage) => {
|
|
29
|
-
const subBaggage = vatData.provideDurableMapStore(baggage, 'sub');
|
|
30
|
-
|
|
31
|
-
const myThis = Object.freeze({ state: { nick: 'Singly' } });
|
|
32
|
-
const singly = vatData.prepareExo(subBaggage, 'a', g.combinedGuard, {
|
|
33
|
-
...g.bindAllMethodsTo(g.greetFacet, myThis),
|
|
34
|
-
...g.bindAllMethodsTo(g.adminFacet, myThis),
|
|
35
|
-
});
|
|
36
|
-
testGreeter(t, 'Singly', singly);
|
|
37
|
-
|
|
38
|
-
const makeGreeter = vatData.prepareExoClass(
|
|
39
|
-
subBaggage,
|
|
40
|
-
'Greeter',
|
|
41
|
-
g.combinedGuard,
|
|
42
|
-
nick => ({ nick }),
|
|
43
|
-
{
|
|
44
|
-
...g.greetFacet,
|
|
45
|
-
...g.adminFacet,
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
const classy = makeGreeter('Classy');
|
|
49
|
-
testGreeter(t, 'Classy', classy);
|
|
50
|
-
|
|
51
|
-
const makeGreeterKit = vatData.prepareExoClassKit(
|
|
52
|
-
subBaggage,
|
|
53
|
-
'GreeterKit',
|
|
54
|
-
{ greeter: g.greetGuard, admin: g.adminGuard },
|
|
55
|
-
nick => ({ nick }),
|
|
56
|
-
{
|
|
57
|
-
greeter: g.greetFacet,
|
|
58
|
-
admin: g.adminFacet,
|
|
59
|
-
},
|
|
60
|
-
);
|
|
61
|
-
const { greeter: kitty, admin: kittyAdmin } = makeGreeterKit('Kitty');
|
|
62
|
-
testGreeter(t, 'Kitty', kitty, kittyAdmin);
|
|
63
|
-
|
|
64
|
-
const mappish = vatData.provideDurableMapStore(subBaggage, 'mappish');
|
|
65
|
-
mappish.init('singly', singly);
|
|
66
|
-
mappish.init('classy', classy);
|
|
67
|
-
mappish.init('kitty', kitty);
|
|
68
|
-
mappish.init('kittyAdmin', kittyAdmin);
|
|
69
|
-
|
|
70
|
-
vatData.provideDurableMapStore(subBaggage, 'subsub');
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
test('heapZone', t => {
|
|
74
|
-
const zone = makeHeapZone();
|
|
75
|
-
testFirstZoneIncarnation(t, zone);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test.serial('virtualZone', t => {
|
|
79
|
-
annihilate();
|
|
80
|
-
const zone = makeVirtualZone();
|
|
81
|
-
testFirstZoneIncarnation(t, zone);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test.serial('durableZone', t => {
|
|
85
|
-
annihilate();
|
|
86
|
-
|
|
87
|
-
const expectedKeys = [
|
|
88
|
-
...keys.exo('a'),
|
|
89
|
-
...keys.exoClass('Greeter'),
|
|
90
|
-
...keys.exoClassKit('GreeterKit'),
|
|
91
|
-
...keys.store('mappish'),
|
|
92
|
-
...keys.zone('subsub'),
|
|
93
|
-
].sort();
|
|
94
|
-
t.deepEqual(agoricVatDataCompatibleKeys, expectedKeys);
|
|
95
|
-
|
|
96
|
-
nextLife();
|
|
97
|
-
const baggage1 = getBaggage();
|
|
98
|
-
testFirstZoneIncarnation(t, makeDurableZone(baggage1));
|
|
99
|
-
t.deepEqual(
|
|
100
|
-
[...baggage1.get('sub').keys()].sort(),
|
|
101
|
-
agoricVatDataCompatibleKeys,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
nextLife();
|
|
105
|
-
const baggage2 = getBaggage();
|
|
106
|
-
t.deepEqual(
|
|
107
|
-
[...baggage2.get('sub').keys()].sort(),
|
|
108
|
-
agoricVatDataCompatibleKeys,
|
|
109
|
-
);
|
|
110
|
-
testSecondZoneIncarnation(t, makeDurableZone(baggage2));
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test.serial('vatData migrate to durableZone', t => {
|
|
114
|
-
annihilate();
|
|
115
|
-
|
|
116
|
-
const baggage1 = getBaggage();
|
|
117
|
-
testFirstVatDataIncarnation(t, baggage1);
|
|
118
|
-
t.deepEqual(
|
|
119
|
-
[...baggage1.get('sub').keys()].sort(),
|
|
120
|
-
agoricVatDataCompatibleKeys,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
nextLife();
|
|
124
|
-
const baggage2 = getBaggage();
|
|
125
|
-
testSecondZoneIncarnation(t, makeDurableZone(baggage2));
|
|
126
|
-
});
|
package/test/test-make-once.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
annihilate,
|
|
3
|
-
getBaggage,
|
|
4
|
-
nextLife,
|
|
5
|
-
test,
|
|
6
|
-
} from './prepare-test-env-ava.js';
|
|
7
|
-
|
|
8
|
-
import { makeDurableZone } from '../durable.js';
|
|
9
|
-
import { makeHeapZone } from '../heap.js';
|
|
10
|
-
import { makeVirtualZone } from '../virtual.js';
|
|
11
|
-
|
|
12
|
-
/** @typedef {import('../src/index.js').Zone} Zone */
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {import('ava').Assertions} t
|
|
16
|
-
* @param {Zone} rootZone
|
|
17
|
-
*/
|
|
18
|
-
const testOnce = (t, rootZone) => {
|
|
19
|
-
const subZone = rootZone.subZone('sub');
|
|
20
|
-
const a = subZone.makeOnce('a', () => 'A');
|
|
21
|
-
t.is(a, 'A');
|
|
22
|
-
t.throws(() => subZone.makeOnce('a', () => 'A'), {
|
|
23
|
-
message: /has already been used/,
|
|
24
|
-
});
|
|
25
|
-
const nonPassable = harden({
|
|
26
|
-
hello() {
|
|
27
|
-
return 'world';
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
t.is(rootZone.isStorable(nonPassable), false);
|
|
31
|
-
t.is(subZone.isStorable(123), true);
|
|
32
|
-
t.throws(() => rootZone.makeOnce('nonPassable', () => nonPassable), {
|
|
33
|
-
message: /is not storable/,
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
test('heapZone', t => {
|
|
38
|
-
testOnce(t, makeHeapZone());
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test.serial('virtualZone', t => {
|
|
42
|
-
testOnce(t, makeVirtualZone());
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test.serial('durableZone', t => {
|
|
46
|
-
annihilate();
|
|
47
|
-
const rootBaggage = getBaggage();
|
|
48
|
-
const rootDurableZone = makeDurableZone(rootBaggage);
|
|
49
|
-
testOnce(t, rootDurableZone);
|
|
50
|
-
|
|
51
|
-
// Do we actually want to refuse to use the same baggage twice?
|
|
52
|
-
const secondDurableZone = makeDurableZone(rootBaggage);
|
|
53
|
-
testOnce(t, secondDurableZone);
|
|
54
|
-
const subDurableZone = makeDurableZone(rootBaggage).subZone('sub');
|
|
55
|
-
t.is(
|
|
56
|
-
subDurableZone.makeOnce('a', () => 'B'),
|
|
57
|
-
'A',
|
|
58
|
-
);
|
|
59
|
-
t.throws(() => subDurableZone.makeOnce('a', () => 'B'), {
|
|
60
|
-
message: /has already been used/,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
nextLife();
|
|
64
|
-
const thirdDurableZone = makeDurableZone(getBaggage());
|
|
65
|
-
testOnce(t, thirdDurableZone);
|
|
66
|
-
});
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/virtual.d.ts
DELETED
package/virtual.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["virtual.js"],"names":[],"mappings":""}
|