@agoric/swingset-liveslots 0.10.3-other-dev-8f8782b.0 → 0.10.3-other-dev-fbe72e7.0.fbe72e7
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/README.md +2 -0
- package/package.json +34 -26
- package/src/boyd-gc.d.ts +12 -0
- package/src/boyd-gc.d.ts.map +1 -0
- package/src/boyd-gc.js +598 -0
- package/src/cache.d.ts +71 -0
- package/src/cache.d.ts.map +1 -0
- package/src/cache.js +3 -2
- package/src/capdata.d.ts +16 -0
- package/src/capdata.d.ts.map +1 -0
- package/src/capdata.js +17 -10
- package/src/collectionManager.d.ts +47 -0
- package/src/collectionManager.d.ts.map +1 -0
- package/src/collectionManager.js +220 -103
- package/src/facetiousness.d.ts +25 -0
- package/src/facetiousness.d.ts.map +1 -0
- package/src/facetiousness.js +1 -1
- package/src/index.d.ts +4 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +4 -2
- package/src/kdebug.d.ts +7 -0
- package/src/kdebug.d.ts.map +1 -0
- package/src/liveslots.d.ts +42 -0
- package/src/liveslots.d.ts.map +1 -0
- package/src/liveslots.js +137 -305
- package/src/message.d.ts +49 -0
- package/src/message.d.ts.map +1 -0
- package/src/message.js +9 -5
- package/src/parseVatSlots.d.ts +125 -0
- package/src/parseVatSlots.d.ts.map +1 -0
- package/src/parseVatSlots.js +1 -1
- package/src/types-index.d.ts +4 -0
- package/src/types-index.js +2 -0
- package/src/types.d.ts +81 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +14 -7
- package/src/vatDataTypes.d.ts +170 -0
- package/src/vatDataTypes.d.ts.map +1 -0
- package/src/vatDataTypes.ts +272 -0
- package/src/vatstore-iterators.d.ts +4 -0
- package/src/vatstore-iterators.d.ts.map +1 -0
- package/src/vatstore-iterators.js +2 -0
- package/src/vatstore-usage.md +198 -0
- package/src/virtualObjectManager.d.ts +44 -0
- package/src/virtualObjectManager.d.ts.map +1 -0
- package/src/virtualObjectManager.js +254 -84
- package/src/virtualReferences.d.ts +61 -0
- package/src/virtualReferences.d.ts.map +1 -0
- package/src/virtualReferences.js +135 -26
- package/src/vpid-tracking.md +92 -0
- package/src/watchedPromises.d.ts +31 -0
- package/src/watchedPromises.d.ts.map +1 -0
- package/src/watchedPromises.js +81 -24
- package/test/{test-baggage.js → baggage.test.js} +1 -2
- package/test/{test-cache.js → cache.test.js} +0 -1
- package/test/clear-collection.test.js +586 -0
- package/test/{test-collection-schema-refcount.js → collection-schema-refcount.test.js} +1 -2
- package/test/{test-collection-upgrade.js → collection-upgrade.test.js} +1 -3
- package/test/{test-collections.js → collections.test.js} +183 -18
- package/test/{test-dropped-collection-weakrefs.js → dropped-collection-weakrefs.test.js} +1 -2
- package/test/dropped-weakset-9939.test.js +80 -0
- package/test/dummyMeterControl.d.ts +2 -0
- package/test/dummyMeterControl.d.ts.map +1 -0
- package/test/dummyMeterControl.js +1 -1
- package/test/{test-durabilityChecks.js → durabilityChecks.test.js} +4 -4
- package/test/engine-gc.d.ts +3 -0
- package/test/engine-gc.d.ts.map +1 -0
- package/test/exo-utils.js +70 -0
- package/test/{test-facetiousness.js → facetiousness.test.js} +1 -2
- package/test/gc-and-finalize.d.ts +5 -0
- package/test/gc-and-finalize.d.ts.map +1 -0
- package/test/gc-and-finalize.js +30 -1
- package/test/gc-before-finalizer.test.js +230 -0
- package/test/gc-helpers.js +4 -5
- package/test/{test-gc-sensitivity.js → gc-sensitivity.test.js} +2 -2
- package/test/handled-promises.test.js +872 -0
- package/test/{test-initial-vrefs.js → initial-vrefs.test.js} +13 -20
- package/test/liveslots-helpers.d.ts +64 -0
- package/test/liveslots-helpers.d.ts.map +1 -0
- package/test/liveslots-helpers.js +13 -7
- package/test/{test-liveslots-mock-gc.js → liveslots-mock-gc.test.js} +101 -2
- package/test/{test-liveslots-real-gc.js → liveslots-real-gc.test.js} +73 -46
- package/test/{test-liveslots.js → liveslots.test.js} +17 -18
- package/test/mock-gc.js +1 -0
- package/test/storeGC/{test-lifecycle.js → lifecycle.test.js} +15 -14
- package/test/storeGC/{test-refcount-management.js → refcount-management.test.js} +1 -2
- package/test/storeGC/{test-scalar-store-kind.js → scalar-store-kind.test.js} +0 -1
- package/test/storeGC/{test-weak-key.js → weak-key.test.js} +1 -2
- package/test/strict-test-env-upgrade.test.js +94 -0
- package/test/util.d.ts +25 -0
- package/test/util.d.ts.map +1 -0
- package/test/util.js +4 -4
- package/test/vat-environment.test.js +65 -0
- package/test/vat-util.d.ts +9 -0
- package/test/vat-util.d.ts.map +1 -0
- package/test/vat-util.js +2 -2
- package/test/virtual-objects/{test-cease-recognition.js → cease-recognition.test.js} +2 -2
- package/test/virtual-objects/{test-cross-facet.js → cross-facet.test.js} +5 -4
- package/test/virtual-objects/{test-empty-data.js → empty-data.test.js} +1 -2
- package/test/virtual-objects/{test-facets.js → facets.test.js} +1 -2
- package/test/virtual-objects/{test-kind-changes.js → kind-changes.test.js} +2 -2
- package/test/virtual-objects/{test-reachable-vrefs.js → reachable-vrefs.test.js} +2 -2
- package/test/virtual-objects/{test-rep-tostring.js → rep-tostring.test.js} +3 -5
- package/test/virtual-objects/{test-retain-remotable.js → retain-remotable.test.js} +25 -24
- package/test/virtual-objects/set-debug-label-instances.js +1 -1
- package/test/virtual-objects/state-shape.test.js +389 -0
- package/test/virtual-objects/{test-virtualObjectGC.js → virtualObjectGC.test.js} +39 -38
- package/test/virtual-objects/{test-virtualObjectManager.js → virtualObjectManager.test.js} +104 -8
- package/test/virtual-objects/{test-vo-real-gc.js → vo-real-gc.test.js} +8 -8
- package/test/virtual-objects/{test-weakcollections-vref-handling.js → weakcollections-vref-handling.test.js} +1 -2
- package/test/{test-vo-test-harness.js → vo-test-harness.test.js} +13 -10
- package/test/{test-vpid-liveslots.js → vpid-liveslots.test.js} +105 -5
- package/test/waitUntilQuiescent.d.ts +3 -0
- package/test/waitUntilQuiescent.d.ts.map +1 -0
- package/test/waitUntilQuiescent.js +2 -1
- package/test/weakset-dropped-remotable.test.js +50 -0
- package/tools/fakeCollectionManager.d.ts +14 -0
- package/tools/fakeCollectionManager.d.ts.map +1 -0
- package/tools/fakeCollectionManager.js +44 -0
- package/tools/fakeVirtualObjectManager.d.ts +32 -0
- package/tools/fakeVirtualObjectManager.d.ts.map +1 -0
- package/tools/fakeVirtualObjectManager.js +62 -0
- package/tools/fakeVirtualSupport.d.ts +278 -0
- package/tools/fakeVirtualSupport.d.ts.map +1 -0
- package/tools/fakeVirtualSupport.js +389 -0
- package/tools/prepare-strict-test-env.d.ts +37 -0
- package/tools/prepare-strict-test-env.d.ts.map +1 -0
- package/tools/prepare-strict-test-env.js +124 -0
- package/tools/prepare-test-env.d.ts +2 -0
- package/tools/prepare-test-env.d.ts.map +1 -0
- package/tools/prepare-test-env.js +13 -0
- package/tools/setup-vat-data.d.ts +9 -0
- package/tools/setup-vat-data.d.ts.map +1 -0
- package/tools/setup-vat-data.js +95 -0
- package/tools/vo-test-harness.d.ts +33 -0
- package/tools/vo-test-harness.d.ts.map +1 -0
- package/tools/vo-test-harness.js +164 -0
- package/CHANGELOG.md +0 -61
- package/test/kmarshal.js +0 -79
- package/test/test-handled-promises.js +0 -360
- package/test/virtual-objects/test-state-shape.js +0 -298
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '
|
|
3
|
-
import { runVOTest } from '../tools/vo-test-harness.js';
|
|
2
|
+
import { makeSpy, runVOTest } from '../tools/vo-test-harness.js';
|
|
4
3
|
|
|
5
4
|
async function voTestTest(t, mode) {
|
|
6
5
|
let makeThing;
|
|
@@ -37,8 +36,6 @@ async function voTestTest(t, mode) {
|
|
|
37
36
|
await runVOTest(t, prepare, makeTestThing, testTestThing);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
// Note: these first two are not marked "test.failing" because
|
|
41
|
-
// something is wrong and we need to fix it. Rather, they are
|
|
42
39
|
// confirming that the voTestTest harness would catch problems during
|
|
43
40
|
// downstream tests that use the harness, if those problems arose in
|
|
44
41
|
// the "before" or "after" phases, and reported by the downstream test
|
|
@@ -48,20 +45,26 @@ async function voTestTest(t, mode) {
|
|
|
48
45
|
// fails, otherwise the harness is not doing its job, and is hiding
|
|
49
46
|
// real test failures in some downstream client package.
|
|
50
47
|
|
|
51
|
-
test
|
|
52
|
-
|
|
48
|
+
test('fail during "before" phase', async t => {
|
|
49
|
+
const tSpy = makeSpy(t);
|
|
50
|
+
await voTestTest(tSpy, 'before');
|
|
51
|
+
t.is(tSpy.failureMessage, 'deliberate failure in before phase');
|
|
53
52
|
});
|
|
54
53
|
|
|
55
|
-
test
|
|
56
|
-
|
|
54
|
+
test('fail during "after" phase', async t => {
|
|
55
|
+
const tSpy = makeSpy(t);
|
|
56
|
+
await voTestTest(tSpy, 'after');
|
|
57
|
+
t.is(tSpy.failureMessage, 'deliberate failure in after phase');
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
// Similarly, this test makes sure that our harness can detect when
|
|
60
61
|
// the downstream test misbehaves and holds on to the object they were
|
|
61
62
|
// supposed to drop.
|
|
62
63
|
|
|
63
|
-
test
|
|
64
|
-
|
|
64
|
+
test('fail due to held object', async t => {
|
|
65
|
+
const tSpy = makeSpy(t);
|
|
66
|
+
await voTestTest(tSpy, 'hold');
|
|
67
|
+
t.is(tSpy.falsyMessage, 'somebody continues to hold test object');
|
|
65
68
|
});
|
|
66
69
|
|
|
67
70
|
test.serial('succeed', async t => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
|
+
import { Fail } from '@endo/errors';
|
|
4
5
|
import { E } from '@endo/eventual-send';
|
|
5
6
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
6
|
-
import { Fail } from '@agoric/assert';
|
|
7
7
|
import { Far } from '@endo/marshal';
|
|
8
|
+
import { kser, kslot } from '@agoric/kmarshal';
|
|
8
9
|
import { buildSyscall, makeDispatch } from './liveslots-helpers.js';
|
|
9
10
|
import { makeMessage, makeResolve, makeReject } from './util.js';
|
|
10
|
-
import { kser, kslot } from './kmarshal.js';
|
|
11
11
|
|
|
12
12
|
function hush(p) {
|
|
13
13
|
p.then(
|
|
@@ -293,7 +293,6 @@ async function doVatResolveCase23(t, which, mode, stalls) {
|
|
|
293
293
|
// another few turns. We wait some number of turns before using p1
|
|
294
294
|
// again, to exercise as many race conditions as possible.
|
|
295
295
|
for (let i = 0; i < stalls; i += 1) {
|
|
296
|
-
// eslint-disable-next-line no-await-in-loop
|
|
297
296
|
await Promise.resolve();
|
|
298
297
|
}
|
|
299
298
|
|
|
@@ -858,7 +857,7 @@ test('inter-vat circular promise references', async t => {
|
|
|
858
857
|
let r;
|
|
859
858
|
return Far('root', {
|
|
860
859
|
genPromise() {
|
|
861
|
-
[p, r] = makePR();
|
|
860
|
+
void ([p, r] = makePR());
|
|
862
861
|
return p;
|
|
863
862
|
},
|
|
864
863
|
usePromise(pa) {
|
|
@@ -899,3 +898,104 @@ test('inter-vat circular promise references', async t => {
|
|
|
899
898
|
// });
|
|
900
899
|
// t.deepEqual(log, []);
|
|
901
900
|
});
|
|
901
|
+
|
|
902
|
+
test('accept previously allocated promise', async t => {
|
|
903
|
+
function build(vatPowers, vatParameters) {
|
|
904
|
+
const { target } = vatParameters;
|
|
905
|
+
return Far('root', {
|
|
906
|
+
call() {
|
|
907
|
+
const promise = E(target).foo();
|
|
908
|
+
// wrap to avoid adoption
|
|
909
|
+
return { promise };
|
|
910
|
+
},
|
|
911
|
+
async waitFor(promise2) {
|
|
912
|
+
// if we're in the same incarnation as the `E(target).foo()`, this
|
|
913
|
+
// `promise2` will be the same JS Promise as the `promise` above
|
|
914
|
+
const v = await promise2;
|
|
915
|
+
return v;
|
|
916
|
+
},
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
let log;
|
|
921
|
+
let syscall;
|
|
922
|
+
let dispatch;
|
|
923
|
+
|
|
924
|
+
const kvStore = new Map();
|
|
925
|
+
({ log, syscall } = buildSyscall({ kvStore }));
|
|
926
|
+
|
|
927
|
+
const target = 'o-1';
|
|
928
|
+
({ dispatch } = await makeDispatch(
|
|
929
|
+
syscall,
|
|
930
|
+
build,
|
|
931
|
+
'reimport-promise',
|
|
932
|
+
{},
|
|
933
|
+
{ target: kslot(target) },
|
|
934
|
+
));
|
|
935
|
+
log.length = 0; // assume pre-build vatstore operations are correct
|
|
936
|
+
|
|
937
|
+
const root = 'o+0';
|
|
938
|
+
const callResultP = 'p-1';
|
|
939
|
+
const waitForResultP = 'p-2';
|
|
940
|
+
const expectedP1 = 'p+5';
|
|
941
|
+
|
|
942
|
+
await dispatch(makeMessage(root, 'call', [], callResultP));
|
|
943
|
+
|
|
944
|
+
// The vat should send 'foo', subscribe to the result promise, and resolve with that promise
|
|
945
|
+
t.deepEqual(log.splice(0, 3), [
|
|
946
|
+
{
|
|
947
|
+
type: 'send',
|
|
948
|
+
targetSlot: target,
|
|
949
|
+
methargs: kser(['foo', []]),
|
|
950
|
+
resultSlot: expectedP1,
|
|
951
|
+
},
|
|
952
|
+
{ type: 'subscribe', target: expectedP1 },
|
|
953
|
+
{
|
|
954
|
+
type: 'resolve',
|
|
955
|
+
resolutions: [[callResultP, false, kser({ promise: kslot(expectedP1) })]],
|
|
956
|
+
},
|
|
957
|
+
]);
|
|
958
|
+
matchIDCounterSet(t, log);
|
|
959
|
+
t.deepEqual(log, []);
|
|
960
|
+
|
|
961
|
+
// snapshot the store at this point
|
|
962
|
+
const clonedStore = new Map(kvStore);
|
|
963
|
+
|
|
964
|
+
const verifyPromiseReImport = async shouldSubscribe => {
|
|
965
|
+
await dispatch(
|
|
966
|
+
makeMessage(root, 'waitFor', [kslot(expectedP1)], waitForResultP),
|
|
967
|
+
);
|
|
968
|
+
|
|
969
|
+
// The vat will only subscribe if it was upgraded; if the vat still
|
|
970
|
+
// remembers it, receiving the vref will merely look it up in slotToVal and
|
|
971
|
+
// not create a new Promise (and trigger a subscribe)
|
|
972
|
+
if (shouldSubscribe) {
|
|
973
|
+
t.deepEqual(log.shift(), { type: 'subscribe', target: expectedP1 });
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// waitFor will suspend until promise is resolved
|
|
977
|
+
t.deepEqual(log, []);
|
|
978
|
+
|
|
979
|
+
// Resolution propagates the value to the waitFor result
|
|
980
|
+
await dispatch(makeResolve(expectedP1, kser('success')));
|
|
981
|
+
t.deepEqual(log.shift(), {
|
|
982
|
+
type: 'resolve',
|
|
983
|
+
resolutions: [[waitForResultP, false, kser('success')]],
|
|
984
|
+
});
|
|
985
|
+
t.deepEqual(log, []);
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
await verifyPromiseReImport(false);
|
|
989
|
+
({ log, syscall } = buildSyscall({ kvStore: clonedStore }));
|
|
990
|
+
({ dispatch } = await makeDispatch(
|
|
991
|
+
syscall,
|
|
992
|
+
build,
|
|
993
|
+
'reimport-promise-v2',
|
|
994
|
+
{},
|
|
995
|
+
{},
|
|
996
|
+
));
|
|
997
|
+
log.length = 0;
|
|
998
|
+
|
|
999
|
+
// verify this works the same in the restarted vat
|
|
1000
|
+
await verifyPromiseReImport(true);
|
|
1001
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitUntilQuiescent.d.ts","sourceRoot":"","sources":["waitUntilQuiescent.js"],"names":[],"mappings":"AAGA,oDAAoD;AAKpD,oDAWC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* global setImmediate */
|
|
2
2
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
/** @import {PromiseKit} from '@endo/promise-kit' */
|
|
4
5
|
|
|
5
6
|
// This can only be imported from the Start Compartment, where 'setImmediate'
|
|
6
7
|
// is available.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { Far } from '@endo/marshal';
|
|
3
|
+
import { kser, kslot } from '@agoric/kmarshal';
|
|
4
|
+
import { makeLiveSlots } from '../src/liveslots.js';
|
|
5
|
+
import { buildSyscall } from './liveslots-helpers.js';
|
|
6
|
+
import { makeStartVat, makeMessage, makeBringOutYourDead } from './util.js';
|
|
7
|
+
import { makeMockGC } from './mock-gc.js';
|
|
8
|
+
|
|
9
|
+
// Test for https://github.com/Agoric/agoric-sdk/issues/9956
|
|
10
|
+
|
|
11
|
+
test('delete remotable key from weakset', async t => {
|
|
12
|
+
const { syscall, log } = buildSyscall();
|
|
13
|
+
const gcTools = makeMockGC();
|
|
14
|
+
const rem = Far('remotable', {});
|
|
15
|
+
|
|
16
|
+
function buildRootObject(vatPowers) {
|
|
17
|
+
const { VatData } = vatPowers;
|
|
18
|
+
const { makeScalarBigWeakMapStore } = VatData;
|
|
19
|
+
const wms = makeScalarBigWeakMapStore();
|
|
20
|
+
return Far('root', {
|
|
21
|
+
store: p => {
|
|
22
|
+
wms.init(rem, p);
|
|
23
|
+
gcTools.kill(p);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const makeNS = () => ({ buildRootObject });
|
|
29
|
+
const ls = makeLiveSlots(syscall, 'vatA', {}, {}, gcTools, undefined, makeNS);
|
|
30
|
+
const { dispatch } = ls;
|
|
31
|
+
await dispatch(makeStartVat(kser()));
|
|
32
|
+
|
|
33
|
+
await dispatch(makeMessage('o+0', 'store', [kslot('o-1')]));
|
|
34
|
+
|
|
35
|
+
// pretend the Remotable was dropped from RAM
|
|
36
|
+
log.length = 0;
|
|
37
|
+
gcTools.kill(rem);
|
|
38
|
+
gcTools.flushAllFRs();
|
|
39
|
+
await dispatch(makeBringOutYourDead());
|
|
40
|
+
|
|
41
|
+
// that ought to emit a drop and retire for the presence
|
|
42
|
+
const gcCalls = log.filter(
|
|
43
|
+
l => l.type === 'dropImports' || l.type === 'retireImports',
|
|
44
|
+
);
|
|
45
|
+
t.deepEqual(gcCalls, [
|
|
46
|
+
{ type: 'dropImports', slots: ['o-1'] },
|
|
47
|
+
{ type: 'retireImports', slots: ['o-1'] },
|
|
48
|
+
]);
|
|
49
|
+
log.length = 0;
|
|
50
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function makeFakeCollectionManager(vrm: any, fakeStuff: any, _options?: {}): {
|
|
2
|
+
getValForSlot: any;
|
|
3
|
+
setValForSlot: any;
|
|
4
|
+
registerEntry: any;
|
|
5
|
+
deleteEntry: any;
|
|
6
|
+
dumpStore: any;
|
|
7
|
+
makeScalarBigMapStore: <K, V>(label?: string, options?: StoreOptions) => MapStore<K, V>;
|
|
8
|
+
makeScalarBigWeakMapStore: <K, V>(label?: string, options?: StoreOptions) => WeakMapStore<K, V>;
|
|
9
|
+
makeScalarBigSetStore: <K>(label?: string, options?: StoreOptions) => SetStore<K>;
|
|
10
|
+
makeScalarBigWeakSetStore: <K>(label?: string, options?: StoreOptions) => WeakSetStore<K>;
|
|
11
|
+
provideBaggage: () => any;
|
|
12
|
+
flushSchemaCache: () => void;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=fakeCollectionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakeCollectionManager.d.ts","sourceRoot":"","sources":["fakeCollectionManager.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;EAyCC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { makeCollectionManager } from '../src/collectionManager.js';
|
|
2
|
+
|
|
3
|
+
export function makeFakeCollectionManager(vrm, fakeStuff, _options = {}) {
|
|
4
|
+
const {
|
|
5
|
+
makeScalarBigMapStore,
|
|
6
|
+
makeScalarBigWeakMapStore,
|
|
7
|
+
makeScalarBigSetStore,
|
|
8
|
+
makeScalarBigWeakSetStore,
|
|
9
|
+
provideBaggage,
|
|
10
|
+
initializeStoreKindInfo,
|
|
11
|
+
flushSchemaCache,
|
|
12
|
+
} = makeCollectionManager(
|
|
13
|
+
fakeStuff.syscall,
|
|
14
|
+
vrm,
|
|
15
|
+
fakeStuff.allocateExportID,
|
|
16
|
+
fakeStuff.allocateCollectionID,
|
|
17
|
+
fakeStuff.convertValToSlot,
|
|
18
|
+
fakeStuff.convertSlotToVal,
|
|
19
|
+
fakeStuff.registerEntry,
|
|
20
|
+
fakeStuff.marshal.serialize,
|
|
21
|
+
fakeStuff.marshal.unserialize,
|
|
22
|
+
fakeStuff.assertAcceptableSyscallCapdataSize,
|
|
23
|
+
);
|
|
24
|
+
initializeStoreKindInfo();
|
|
25
|
+
|
|
26
|
+
const normalCM = {
|
|
27
|
+
makeScalarBigMapStore,
|
|
28
|
+
makeScalarBigWeakMapStore,
|
|
29
|
+
makeScalarBigSetStore,
|
|
30
|
+
makeScalarBigWeakSetStore,
|
|
31
|
+
provideBaggage,
|
|
32
|
+
flushSchemaCache,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const debugTools = {
|
|
36
|
+
getValForSlot: fakeStuff.getValForSlot,
|
|
37
|
+
setValForSlot: fakeStuff.setValForSlot,
|
|
38
|
+
registerEntry: fakeStuff.registerEntry,
|
|
39
|
+
deleteEntry: fakeStuff.deleteEntry,
|
|
40
|
+
dumpStore: fakeStuff.dumpStore,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return harden({ ...normalCM, ...debugTools });
|
|
44
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function makeFakeVirtualObjectManager(vrm: any, fakeStuff: any): {
|
|
2
|
+
getValForSlot: any;
|
|
3
|
+
setValForSlot: any;
|
|
4
|
+
registerEntry: any;
|
|
5
|
+
deleteEntry: any;
|
|
6
|
+
flushStateCache: () => void;
|
|
7
|
+
dumpStore: any;
|
|
8
|
+
initializeKindHandleKind: () => void;
|
|
9
|
+
defineKind: <P extends Array<any>, S, F>(tag: string, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
10
|
+
defineKindMulti: <P extends Array<any>, S, B>(tag: string, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
11
|
+
defineDurableKind: <P extends Array<any>, S, F>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, facet: F, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").KindContext<S, F>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacet<F>;
|
|
12
|
+
defineDurableKindMulti: <P extends Array<any>, S, B>(kindHandle: import("../src/vatDataTypes.js").DurableKindHandle, init: (...args: P) => S, behavior: B, options?: import("../src/vatDataTypes.js").DefineKindOptions<import("../src/vatDataTypes.js").MultiKindContext<S, B>>) => (...args: P) => import("../src/vatDataTypes.js").KindFacets<B>;
|
|
13
|
+
makeKindHandle: (tag: string) => import("../src/vatDataTypes.js").DurableKindHandle;
|
|
14
|
+
canBeDurable: (specimen: any) => boolean;
|
|
15
|
+
insistAllDurableKindsReconnected: () => void;
|
|
16
|
+
VirtualObjectAwareWeakMap: {
|
|
17
|
+
new (): {
|
|
18
|
+
has(key: any): any;
|
|
19
|
+
get(key: any): any;
|
|
20
|
+
set(key: any, value: any): /*elided*/ any;
|
|
21
|
+
delete(key: any): any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
VirtualObjectAwareWeakSet: {
|
|
25
|
+
new (): {
|
|
26
|
+
has(value: any): any;
|
|
27
|
+
add(value: any): /*elided*/ any;
|
|
28
|
+
delete(value: any): any;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=fakeVirtualObjectManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakeVirtualObjectManager.d.ts","sourceRoot":"","sources":["fakeVirtualObjectManager.js"],"names":[],"mappings":"AAaA;;;;;;;;iEAiDywJ,GAAG,+IAAyF,GAAG;sEAAkK,GAAG,uJAAiG,GAAG;2HAAyQ,GAAG,+IAAyF,GAAG;gIAA2L,GAAG,uJAAiG,GAAG;;;;;;;;;;;;;;;;;;;EAD1vL"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { makeVirtualObjectManager } from '../src/virtualObjectManager.js';
|
|
2
|
+
|
|
3
|
+
// Note: `fakeVirtualObjectManager` is something of a misnomer here. The
|
|
4
|
+
// virtual object manager being used to implement this realized by the actual
|
|
5
|
+
// virtual object manager code. What's being faked is everything else the
|
|
6
|
+
// virtual object manager is embedded in, i.e., the kernel and the rest of
|
|
7
|
+
// liveslots. In particular, this module can be (and is, and is intended to be)
|
|
8
|
+
// used for unit tests for the virtual object manager itself. What you get back
|
|
9
|
+
// from `makeFakeVirtualObjectManager` can't be used to program as if you were
|
|
10
|
+
// running in a vat because the rest of the vat environment is not present, but
|
|
11
|
+
// it *will* execute virtual object manager operations in the same way that the
|
|
12
|
+
// real one will because underneath it *is* the real one.
|
|
13
|
+
|
|
14
|
+
export function makeFakeVirtualObjectManager(vrm, fakeStuff) {
|
|
15
|
+
const {
|
|
16
|
+
initializeKindHandleKind,
|
|
17
|
+
defineKind,
|
|
18
|
+
defineKindMulti,
|
|
19
|
+
defineDurableKind,
|
|
20
|
+
defineDurableKindMulti,
|
|
21
|
+
makeKindHandle,
|
|
22
|
+
VirtualObjectAwareWeakMap,
|
|
23
|
+
VirtualObjectAwareWeakSet,
|
|
24
|
+
flushStateCache,
|
|
25
|
+
canBeDurable,
|
|
26
|
+
insistAllDurableKindsReconnected,
|
|
27
|
+
} = makeVirtualObjectManager(
|
|
28
|
+
fakeStuff.syscall,
|
|
29
|
+
vrm,
|
|
30
|
+
fakeStuff.allocateExportID,
|
|
31
|
+
fakeStuff.getSlotForVal,
|
|
32
|
+
fakeStuff.requiredValForSlot,
|
|
33
|
+
fakeStuff.registerEntry,
|
|
34
|
+
fakeStuff.marshal.serialize,
|
|
35
|
+
fakeStuff.marshal.unserialize,
|
|
36
|
+
fakeStuff.assertAcceptableSyscallCapdataSize,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const normalVOM = {
|
|
40
|
+
initializeKindHandleKind,
|
|
41
|
+
defineKind,
|
|
42
|
+
defineKindMulti,
|
|
43
|
+
defineDurableKind,
|
|
44
|
+
defineDurableKindMulti,
|
|
45
|
+
makeKindHandle,
|
|
46
|
+
canBeDurable,
|
|
47
|
+
insistAllDurableKindsReconnected,
|
|
48
|
+
VirtualObjectAwareWeakMap,
|
|
49
|
+
VirtualObjectAwareWeakSet,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const debugTools = {
|
|
53
|
+
getValForSlot: fakeStuff.getValForSlot,
|
|
54
|
+
setValForSlot: fakeStuff.setValForSlot,
|
|
55
|
+
registerEntry: fakeStuff.registerEntry,
|
|
56
|
+
deleteEntry: fakeStuff.deleteEntry,
|
|
57
|
+
flushStateCache,
|
|
58
|
+
dumpStore: fakeStuff.dumpStore,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return harden({ ...normalVOM, ...debugTools });
|
|
62
|
+
}
|