@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,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 { Far } from '@endo/marshal';
|
|
6
7
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
7
|
-
import {
|
|
8
|
+
import { kslot, kser, kunser } from '@agoric/kmarshal';
|
|
8
9
|
import { M } from '@agoric/store';
|
|
9
10
|
import { makeLiveSlots, makeMarshaller } from '../src/liveslots.js';
|
|
10
|
-
import { kslot, kser, kunser } from './kmarshal.js';
|
|
11
11
|
import { buildSyscall, makeDispatch } from './liveslots-helpers.js';
|
|
12
12
|
import { makeMessage, makeStartVat, makeResolve, makeReject } from './util.js';
|
|
13
13
|
import { makeMockGC } from './mock-gc.js';
|
|
@@ -45,14 +45,14 @@ test('calls', async t => {
|
|
|
45
45
|
|
|
46
46
|
// root!one() // sendOnly
|
|
47
47
|
await dispatch(makeMessage(rootA, 'one', ['args']));
|
|
48
|
-
t.
|
|
48
|
+
t.is(log.shift(), 'one');
|
|
49
49
|
|
|
50
50
|
// pr = makePromise()
|
|
51
51
|
// root!two(pr.promise)
|
|
52
52
|
// pr.resolve('result')
|
|
53
53
|
await dispatch(makeMessage(rootA, 'two', [kslot('p-1')]));
|
|
54
54
|
t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-1' });
|
|
55
|
-
t.
|
|
55
|
+
t.is(log.shift(), 'two true');
|
|
56
56
|
|
|
57
57
|
await dispatch(makeResolve('p-1', kser('result')));
|
|
58
58
|
t.deepEqual(log.shift(), ['res', 'result']);
|
|
@@ -63,7 +63,7 @@ test('calls', async t => {
|
|
|
63
63
|
|
|
64
64
|
await dispatch(makeMessage(rootA, 'two', [kslot('p-2')]));
|
|
65
65
|
t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-2' });
|
|
66
|
-
t.
|
|
66
|
+
t.is(log.shift(), 'two true');
|
|
67
67
|
|
|
68
68
|
await dispatch(makeReject('p-2', kser('rejection')));
|
|
69
69
|
t.deepEqual(log.shift(), ['rej', 'rejection']);
|
|
@@ -99,7 +99,7 @@ test('liveslots pipelines to syscall.send', async t => {
|
|
|
99
99
|
// for x!pipe1(), a second pipelined to the result promise of it, and a
|
|
100
100
|
// third pipelined to the result of the second.
|
|
101
101
|
|
|
102
|
-
t.
|
|
102
|
+
t.is(log.shift(), 'sent p1p2p3');
|
|
103
103
|
t.deepEqual(log.shift(), {
|
|
104
104
|
type: 'send',
|
|
105
105
|
targetSlot: x,
|
|
@@ -656,8 +656,7 @@ test('capdata size limit on syscalls', async t => {
|
|
|
656
656
|
};
|
|
657
657
|
|
|
658
658
|
const send = op => dispatch(makeMessage(rootA, op, [kslot(target)], rp));
|
|
659
|
-
const expectFail = () =>
|
|
660
|
-
t.deepEqual(log.shift(), 'fail: syscall capdata too large');
|
|
659
|
+
const expectFail = () => t.is(log.shift(), 'fail: syscall capdata too large');
|
|
661
660
|
const expectVoidReturn = () =>
|
|
662
661
|
t.deepEqual(log.shift(), {
|
|
663
662
|
type: 'resolve',
|
|
@@ -714,7 +713,7 @@ test('capdata size limit on syscalls', async t => {
|
|
|
714
713
|
const label = 'test';
|
|
715
714
|
t.deepEqual(log.shift(), {
|
|
716
715
|
type: 'vatstoreGet',
|
|
717
|
-
key: 'vc.
|
|
716
|
+
key: 'vc.4.|schemata',
|
|
718
717
|
result: JSON.stringify(kser({ label, keyShape: M.scalar() })),
|
|
719
718
|
});
|
|
720
719
|
};
|
|
@@ -724,7 +723,7 @@ test('capdata size limit on syscalls', async t => {
|
|
|
724
723
|
gotSchema();
|
|
725
724
|
t.deepEqual(log.shift(), {
|
|
726
725
|
type: 'vatstoreGet',
|
|
727
|
-
key: 'vc.
|
|
726
|
+
key: 'vc.4.skey',
|
|
728
727
|
result: undefined,
|
|
729
728
|
});
|
|
730
729
|
expectFail();
|
|
@@ -736,7 +735,7 @@ test('capdata size limit on syscalls', async t => {
|
|
|
736
735
|
gotSchema();
|
|
737
736
|
t.deepEqual(log.shift(), {
|
|
738
737
|
type: 'vatstoreGet',
|
|
739
|
-
key: 'vc.
|
|
738
|
+
key: 'vc.4.skey',
|
|
740
739
|
result: undefined,
|
|
741
740
|
});
|
|
742
741
|
expectFail();
|
|
@@ -906,7 +905,7 @@ test('disable disavow', async t => {
|
|
|
906
905
|
|
|
907
906
|
// root~.one() // sendOnly
|
|
908
907
|
await dispatch(makeMessage(rootA, 'one', []));
|
|
909
|
-
t.
|
|
908
|
+
t.is(log.shift(), false);
|
|
910
909
|
t.deepEqual(log, []);
|
|
911
910
|
});
|
|
912
911
|
|
|
@@ -967,7 +966,7 @@ test('disavow', async t => {
|
|
|
967
966
|
// root~.one(import1) // sendOnly
|
|
968
967
|
await dispatch(makeMessage(rootA, 'one', [kslot(import1)]));
|
|
969
968
|
t.deepEqual(log.shift(), { type: 'dropImports', slots: [import1] });
|
|
970
|
-
t.
|
|
969
|
+
t.is(log.shift(), 'disavowed pres1');
|
|
971
970
|
|
|
972
971
|
function loggedError(re) {
|
|
973
972
|
const l = log.shift();
|
|
@@ -975,11 +974,11 @@ test('disavow', async t => {
|
|
|
975
974
|
t.truthy(re.test(l.message));
|
|
976
975
|
}
|
|
977
976
|
loggedError(/attempt to disavow unknown/);
|
|
978
|
-
t.
|
|
977
|
+
t.is(log.shift(), 'tried duplicate disavow');
|
|
979
978
|
loggedError(/attempt to disavow unknown/);
|
|
980
|
-
t.
|
|
979
|
+
t.is(log.shift(), 'tried to disavow Promise');
|
|
981
980
|
loggedError(/attempt to disavow an export/);
|
|
982
|
-
t.
|
|
981
|
+
t.is(log.shift(), 'tried to disavow export');
|
|
983
982
|
const msg = log.shift();
|
|
984
983
|
t.like(msg, {
|
|
985
984
|
type: 'exit',
|
|
@@ -987,7 +986,7 @@ test('disavow', async t => {
|
|
|
987
986
|
});
|
|
988
987
|
expectError(t, msg.info, /this Presence has been disavowed/);
|
|
989
988
|
t.deepEqual(log.shift(), Error('this Presence has been disavowed'));
|
|
990
|
-
t.
|
|
989
|
+
t.is(log.shift(), 'tried to send to disavowed');
|
|
991
990
|
t.deepEqual(log, []);
|
|
992
991
|
});
|
|
993
992
|
|
package/test/mock-gc.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@
|
|
3
|
+
import { avaRetry } from '@agoric/internal/tools/avaRetry.js';
|
|
3
4
|
|
|
5
|
+
import { kslot, kunser } from '@agoric/kmarshal';
|
|
4
6
|
import {
|
|
5
7
|
setupTestLiveslots,
|
|
6
8
|
findSyscallsByType,
|
|
7
9
|
} from '../liveslots-helpers.js';
|
|
8
10
|
import { buildRootObject, mainHeldIdx, mapRef } from '../gc-helpers.js';
|
|
9
|
-
import { kslot, kunser } from '../kmarshal.js';
|
|
10
11
|
import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
11
12
|
|
|
12
13
|
// These tests follow the model described in
|
|
@@ -14,12 +15,12 @@ import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
|
14
15
|
|
|
15
16
|
function getLastCollection(v) {
|
|
16
17
|
// makeAndHold() uses makeScalarBigMapStore, and since we call it
|
|
17
|
-
// early, it always gets "store #
|
|
18
|
-
// scalarMapStore, non-durable, and /
|
|
19
|
-
const vref = 'o+v2/
|
|
18
|
+
// early, it always gets "store #5", in vref o+2/5 (o+2 means
|
|
19
|
+
// scalarMapStore, non-durable, and /5 means collectionID=5)
|
|
20
|
+
const vref = 'o+v2/5';
|
|
20
21
|
// double-check that at least the collectionID is right
|
|
21
22
|
const { t, fakestore } = v;
|
|
22
|
-
t.is(JSON.parse(fakestore.get('idCounters')).collectionID,
|
|
23
|
+
t.is(JSON.parse(fakestore.get('idCounters')).collectionID, 6); // last was 5
|
|
23
24
|
return vref;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -66,7 +67,7 @@ function assertState(v, vref, reachable, erv) {
|
|
|
66
67
|
// different test.
|
|
67
68
|
|
|
68
69
|
// test 1: lerv -> Lerv -> LerV -> Lerv -> lerv
|
|
69
|
-
test.serial
|
|
70
|
+
avaRetry(test.serial, 'store lifecycle 1', async t => {
|
|
70
71
|
const { v, dispatchMessageSuccessfully } = await setupTestLiveslots(
|
|
71
72
|
t,
|
|
72
73
|
buildRootObject,
|
|
@@ -94,7 +95,7 @@ test.serial('store lifecycle 1', async t => {
|
|
|
94
95
|
|
|
95
96
|
// test 2: lerv -> Lerv -> LerV -> lerV -> LerV -> LERV -> lERV -> LERV ->
|
|
96
97
|
// lERV -> LERV -> lERV -> leRV -> LeRV -> leRV -> LeRV -> LerV
|
|
97
|
-
test.serial
|
|
98
|
+
avaRetry(test.serial, 'store lifecycle 2', async t => {
|
|
98
99
|
const {
|
|
99
100
|
v,
|
|
100
101
|
dispatchMessageSuccessfully,
|
|
@@ -170,7 +171,7 @@ test.serial('store lifecycle 2', async t => {
|
|
|
170
171
|
});
|
|
171
172
|
|
|
172
173
|
// test 3: lerv -> Lerv -> LerV -> LERV -> LeRV -> leRV -> lerV -> lerv
|
|
173
|
-
test.serial
|
|
174
|
+
avaRetry(test.serial, 'store lifecycle 3', async t => {
|
|
174
175
|
const {
|
|
175
176
|
v,
|
|
176
177
|
dispatchMessageSuccessfully,
|
|
@@ -211,7 +212,7 @@ test.serial('store lifecycle 3', async t => {
|
|
|
211
212
|
});
|
|
212
213
|
|
|
213
214
|
// test 4: lerv -> Lerv -> LERv -> LeRv -> lerv
|
|
214
|
-
test.serial
|
|
215
|
+
avaRetry(test.serial, 'store lifecycle 4', async t => {
|
|
215
216
|
const { v, dispatchMessageSuccessfully, dispatchDropExports } =
|
|
216
217
|
await setupTestLiveslots(t, buildRootObject, 'bob', { forceGC: true });
|
|
217
218
|
|
|
@@ -239,7 +240,7 @@ test.serial('store lifecycle 4', async t => {
|
|
|
239
240
|
});
|
|
240
241
|
|
|
241
242
|
// test 5: lerv -> Lerv -> LERv -> LeRv -> Lerv -> lerv
|
|
242
|
-
test.serial
|
|
243
|
+
avaRetry(test.serial, 'store lifecycle 5', async t => {
|
|
243
244
|
const {
|
|
244
245
|
v,
|
|
245
246
|
dispatchMessageSuccessfully,
|
|
@@ -277,7 +278,7 @@ test.serial('store lifecycle 5', async t => {
|
|
|
277
278
|
});
|
|
278
279
|
|
|
279
280
|
// test 6: lerv -> Lerv -> LERv -> LeRv -> LeRV -> LeRv -> LeRV -> leRV -> lerv
|
|
280
|
-
test.serial
|
|
281
|
+
avaRetry(test.serial, 'store lifecycle 6', async t => {
|
|
281
282
|
const { v, dispatchMessageSuccessfully, dispatchDropExports } =
|
|
282
283
|
await setupTestLiveslots(t, buildRootObject, 'bob', { forceGC: true });
|
|
283
284
|
|
|
@@ -322,7 +323,7 @@ test.serial('store lifecycle 6', async t => {
|
|
|
322
323
|
});
|
|
323
324
|
|
|
324
325
|
// test 7: lerv -> Lerv -> LERv -> lERv -> LERv -> lERv -> lerv
|
|
325
|
-
test.serial
|
|
326
|
+
avaRetry(test.serial, 'store lifecycle 7', async t => {
|
|
326
327
|
const { v, dispatchMessageSuccessfully, dispatchDropExports } =
|
|
327
328
|
await setupTestLiveslots(t, buildRootObject, 'bob', { forceGC: true });
|
|
328
329
|
|
|
@@ -361,7 +362,7 @@ test.serial('store lifecycle 7', async t => {
|
|
|
361
362
|
});
|
|
362
363
|
|
|
363
364
|
// test 8: lerv -> Lerv -> LERv -> LERV -> LERv -> LERV -> lERV -> lERv -> lerv
|
|
364
|
-
test.serial
|
|
365
|
+
avaRetry(test.serial, 'store lifecycle 8', async t => {
|
|
365
366
|
const { v, dispatchMessageSuccessfully, dispatchDropExports } =
|
|
366
367
|
await setupTestLiveslots(t, buildRootObject, 'bob', { forceGC: true });
|
|
367
368
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
3
|
+
import { kslot } from '@agoric/kmarshal';
|
|
4
4
|
import {
|
|
5
5
|
findSyscallsByType,
|
|
6
6
|
setupTestLiveslots,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
refValString,
|
|
13
13
|
assertCollectionDeleted,
|
|
14
14
|
} from '../gc-helpers.js';
|
|
15
|
-
import { kslot } from '../kmarshal.js';
|
|
16
15
|
import { vstr } from '../util.js';
|
|
17
16
|
|
|
18
17
|
// These tests follow the model described in
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
3
|
+
import { kslot } from '@agoric/kmarshal';
|
|
4
4
|
import { setupTestLiveslots } from '../liveslots-helpers.js';
|
|
5
5
|
import {
|
|
6
6
|
buildRootObject,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
assertCollectionDeleted,
|
|
9
9
|
deduceCollectionID,
|
|
10
10
|
} from '../gc-helpers.js';
|
|
11
|
-
import { kslot } from '../kmarshal.js';
|
|
12
11
|
import { vstr } from '../util.js';
|
|
13
12
|
|
|
14
13
|
// These tests follow the model described in test-virtualObjectGC.js
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* global globalThis */
|
|
2
|
+
// eslint-disable-next-line import/order
|
|
3
|
+
import { annihilate, startLife } from '../tools/prepare-strict-test-env.js';
|
|
4
|
+
|
|
5
|
+
import test from 'ava';
|
|
6
|
+
|
|
7
|
+
import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
|
|
8
|
+
import { makeExoUtils } from './exo-utils.js';
|
|
9
|
+
|
|
10
|
+
test.serial('kind redefinition enforced', async t => {
|
|
11
|
+
annihilate();
|
|
12
|
+
|
|
13
|
+
const { prepareExoClass } = makeExoUtils(globalThis.VatData);
|
|
14
|
+
|
|
15
|
+
await startLife(async baggage => {
|
|
16
|
+
const makeTestExo = prepareExoClass(
|
|
17
|
+
baggage,
|
|
18
|
+
'TestExo',
|
|
19
|
+
undefined,
|
|
20
|
+
() => ({}),
|
|
21
|
+
{
|
|
22
|
+
foo() {
|
|
23
|
+
return 'bar';
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
baggage.init('testExo', makeTestExo());
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await t.throwsAsync(
|
|
32
|
+
async () =>
|
|
33
|
+
startLife(async () => {
|
|
34
|
+
// Not redefining the kind here
|
|
35
|
+
}),
|
|
36
|
+
{ message: 'defineDurableKind not called for tags: [TestExo]' },
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
await startLife(async baggage => {
|
|
40
|
+
prepareExoClass(baggage, 'TestExo', undefined, () => ({}), {
|
|
41
|
+
foo() {
|
|
42
|
+
return 'baz';
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
t.is(baggage.get('testExo').foo(), 'baz');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test.serial('decided promise rejected', async t => {
|
|
51
|
+
annihilate();
|
|
52
|
+
|
|
53
|
+
const { prepareExo } = makeExoUtils(globalThis.VatData);
|
|
54
|
+
const { watchPromise } = globalThis.VatData;
|
|
55
|
+
|
|
56
|
+
t.plan(1);
|
|
57
|
+
|
|
58
|
+
await startLife(async baggage => {
|
|
59
|
+
const watcher = prepareExo(
|
|
60
|
+
baggage,
|
|
61
|
+
'DurablePromiseTestWatcher',
|
|
62
|
+
undefined,
|
|
63
|
+
{
|
|
64
|
+
onFulfilled(value) {
|
|
65
|
+
t.fail(
|
|
66
|
+
`First incarnation watcher onFulfilled triggered with value ${value}`,
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
onRejected(reason) {
|
|
70
|
+
t.fail(
|
|
71
|
+
`First incarnation watcher onRejected triggered with reason ${reason}`,
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const never = harden(new Promise(() => {}));
|
|
78
|
+
|
|
79
|
+
watchPromise(never, watcher);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await startLife(async baggage => {
|
|
83
|
+
prepareExo(baggage, 'DurablePromiseTestWatcher', undefined, {
|
|
84
|
+
onFulfilled(value) {
|
|
85
|
+
t.fail(
|
|
86
|
+
`Second incarnation watcher onFulfilled triggered with value ${value}`,
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
onRejected(reason) {
|
|
90
|
+
t.deepEqual(reason, makeUpgradeDisconnection('vat upgraded', 1));
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
package/test/util.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {(d: unknown) => void} [onDispatchCallback ]
|
|
3
|
+
*/
|
|
4
|
+
export function buildDispatch(onDispatchCallback?: (d: unknown) => void): {
|
|
5
|
+
log: any[];
|
|
6
|
+
dispatch: (vatDeliverObject: any) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @param {unknown} target
|
|
10
|
+
* @param {string | symbol} method
|
|
11
|
+
* @param {any[]} args
|
|
12
|
+
* @param {unknown} result
|
|
13
|
+
*/
|
|
14
|
+
export function makeMessage(target: unknown, method: string | symbol, args?: any[], result?: unknown): unknown[];
|
|
15
|
+
export function makeStartVat(vatParametersCapData?: import("@endo/marshal").CapData<string>): (string | import("@endo/marshal").CapData<string>)[];
|
|
16
|
+
export function makeBringOutYourDead(): string[];
|
|
17
|
+
export function makeResolutions(resolutions: any): any[];
|
|
18
|
+
export function makeResolve(target: any, result: any): any[];
|
|
19
|
+
export function makeReject(target: any, result: any): (string | any[][])[];
|
|
20
|
+
export function makeDropExports(...vrefs: any[]): (string | any[])[];
|
|
21
|
+
export function makeRetireExports(...vrefs: any[]): (string | any[])[];
|
|
22
|
+
export function makeRetireImports(...vrefs: any[]): (string | any[])[];
|
|
23
|
+
export { vstr };
|
|
24
|
+
import { vstr } from './vat-util.js';
|
|
25
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["util.js"],"names":[],"mappings":"AAKA;;GAEG;AACH,mDAFW,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI;;;EAwC9B;AAED;;;;;GAKG;AACH,oCALW,OAAO,UACP,MAAM,GAAG,MAAM,SACf,GAAG,EAAE,WACL,OAAO,aAOjB;AAED,mJAEC;AAED,iDAEC;AAED,yDAGC;AAED,6DAGC;AAED,2EAIC;AAED,qEAGC;AAED,uEAGC;AAED,uEAGC;;qBAjGoB,eAAe"}
|
package/test/util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { kser } from '@agoric/kmarshal';
|
|
1
2
|
import { vstr } from './vat-util.js';
|
|
2
|
-
import { kser } from './kmarshal.js';
|
|
3
3
|
|
|
4
4
|
export { vstr };
|
|
5
5
|
|
|
@@ -48,7 +48,7 @@ export function buildDispatch(onDispatchCallback) {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @param {unknown} target
|
|
51
|
-
* @param {string} method
|
|
51
|
+
* @param {string | symbol} method
|
|
52
52
|
* @param {any[]} args
|
|
53
53
|
* @param {unknown} result
|
|
54
54
|
*/
|
|
@@ -59,8 +59,8 @@ export function makeMessage(target, method, args = [], result = null) {
|
|
|
59
59
|
return vatDeliverObject;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export function makeStartVat(
|
|
63
|
-
return harden(['startVat',
|
|
62
|
+
export function makeStartVat(vatParametersCapData = kser(undefined)) {
|
|
63
|
+
return harden(['startVat', vatParametersCapData]);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export function makeBringOutYourDead() {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import '@endo/init/debug.js';
|
|
3
|
+
import test from 'ava';
|
|
4
|
+
import { Far } from '@endo/marshal';
|
|
5
|
+
import { kser } from '@agoric/kmarshal';
|
|
6
|
+
import { passStyleOf } from '@endo/pass-style';
|
|
7
|
+
import { PassStyleOfEndowmentSymbol } from '@endo/pass-style/endow.js';
|
|
8
|
+
import { makeLiveSlots } from '../src/index.js';
|
|
9
|
+
import { makeStartVat } from './util.js';
|
|
10
|
+
import { buildSyscall } from './liveslots-helpers.js';
|
|
11
|
+
import { makeMockGC } from './mock-gc.js';
|
|
12
|
+
|
|
13
|
+
test('vat globals', async t => {
|
|
14
|
+
const { syscall } = buildSyscall();
|
|
15
|
+
const gcTools = makeMockGC();
|
|
16
|
+
const buildRootObject = () => Far('root', {});
|
|
17
|
+
let called = 0;
|
|
18
|
+
let vatGlobals;
|
|
19
|
+
let inescapableGlobalProperties;
|
|
20
|
+
const vatNS = harden({ buildRootObject });
|
|
21
|
+
// buildVatNamespace
|
|
22
|
+
const bVN = async (vG, iGP) => {
|
|
23
|
+
called += 1;
|
|
24
|
+
vatGlobals = vG;
|
|
25
|
+
inescapableGlobalProperties = iGP;
|
|
26
|
+
return vatNS;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ls = makeLiveSlots(syscall, 'vatA', {}, {}, gcTools, undefined, bVN);
|
|
30
|
+
t.is(called, 0); // not called yet
|
|
31
|
+
await ls.dispatch(makeStartVat(kser()));
|
|
32
|
+
t.is(called, 1);
|
|
33
|
+
t.truthy(vatGlobals);
|
|
34
|
+
|
|
35
|
+
// 'harden' is provided by SES (installed by the lockdown bundle),
|
|
36
|
+
// not liveslots
|
|
37
|
+
t.is(typeof vatGlobals.harden, 'undefined');
|
|
38
|
+
|
|
39
|
+
// but liveslots provides VatData
|
|
40
|
+
t.is(typeof vatGlobals.VatData, 'object');
|
|
41
|
+
t.is(typeof vatGlobals.VatData, 'object');
|
|
42
|
+
t.is(typeof vatGlobals.VatData.defineKind, 'function');
|
|
43
|
+
t.is(typeof vatGlobals.VatData.defineKindMulti, 'function');
|
|
44
|
+
t.is(typeof vatGlobals.VatData.defineDurableKind, 'function');
|
|
45
|
+
t.is(typeof vatGlobals.VatData.defineDurableKindMulti, 'function');
|
|
46
|
+
t.is(typeof vatGlobals.VatData.makeKindHandle, 'function');
|
|
47
|
+
t.is(typeof vatGlobals.VatData.canBeDurable, 'function');
|
|
48
|
+
t.is(typeof vatGlobals.VatData.providePromiseWatcher, 'function');
|
|
49
|
+
t.is(typeof vatGlobals.VatData.watchPromise, 'function');
|
|
50
|
+
t.is(typeof vatGlobals.VatData.makeScalarBigMapStore, 'function');
|
|
51
|
+
t.is(typeof vatGlobals.VatData.makeScalarBigWeakMapStore, 'function');
|
|
52
|
+
t.is(typeof vatGlobals.VatData.makeScalarBigSetStore, 'function');
|
|
53
|
+
t.is(typeof vatGlobals.VatData.makeScalarBigWeakSetStore, 'function');
|
|
54
|
+
|
|
55
|
+
t.is(typeof inescapableGlobalProperties.WeakMap, 'function');
|
|
56
|
+
t.not(inescapableGlobalProperties.WeakMap, WeakMap);
|
|
57
|
+
t.is(typeof inescapableGlobalProperties.WeakSet, 'function');
|
|
58
|
+
t.not(inescapableGlobalProperties.WeakSet, WeakSet);
|
|
59
|
+
t.is(
|
|
60
|
+
typeof inescapableGlobalProperties[PassStyleOfEndowmentSymbol],
|
|
61
|
+
'function',
|
|
62
|
+
);
|
|
63
|
+
// this is the passStyleOf created by liveslots, with a real WeakMap
|
|
64
|
+
t.is(inescapableGlobalProperties[PassStyleOfEndowmentSymbol], passStyleOf);
|
|
65
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function extractMessage(vatDeliverObject: any): {
|
|
2
|
+
facetID: any;
|
|
3
|
+
method: any;
|
|
4
|
+
args: import("@endo/marshal").CapData<string>;
|
|
5
|
+
result: any;
|
|
6
|
+
};
|
|
7
|
+
export function ignore(p: any): void;
|
|
8
|
+
export function vstr(v: any): string;
|
|
9
|
+
//# sourceMappingURL=vat-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vat-util.d.ts","sourceRoot":"","sources":["vat-util.js"],"names":[],"mappings":"AAMA;;;;;EAQC;AAED,qCAKC;AAEM,qCAAyC"}
|
package/test/vat-util.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// this file is imported by some test vats, so don't import any non-pure
|
|
2
2
|
// modules
|
|
3
3
|
|
|
4
|
-
import { Fail } from '@
|
|
5
|
-
import { kser, kunser } from '
|
|
4
|
+
import { Fail } from '@endo/errors';
|
|
5
|
+
import { kser, kunser } from '@agoric/kmarshal';
|
|
6
6
|
|
|
7
7
|
export function extractMessage(vatDeliverObject) {
|
|
8
8
|
const [type, ...vdoargs] = vatDeliverObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/* global FinalizationRegistry WeakRef */
|
|
2
3
|
import test from 'ava';
|
|
3
|
-
import '@endo/init/debug.js';
|
|
4
4
|
|
|
5
5
|
import { buildSyscall } from '../liveslots-helpers.js';
|
|
6
6
|
import { makeVirtualReferenceManager } from '../../src/virtualReferences.js';
|
|
@@ -38,7 +38,7 @@ function weakKeyCheck(t, log, vref) {
|
|
|
38
38
|
t.true(result === undefined || !result.startsWith(prefix), `ew:${result}`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
test('only enumerate virtual objects',
|
|
41
|
+
test('only enumerate virtual objects', t => {
|
|
42
42
|
const { log, vrm } = makeVRM();
|
|
43
43
|
|
|
44
44
|
// retiring a plain Remotable does a is-it-a-weak-key chck
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
4
3
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
4
|
|
|
@@ -15,7 +14,7 @@ function attack2(mut1, immut2) {
|
|
|
15
14
|
Reflect.apply(mutableProto.set, immut2, [6]);
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
test('forbid cross-facet prototype attack',
|
|
17
|
+
test('forbid cross-facet prototype attack', t => {
|
|
19
18
|
const vom = makeFakeVirtualObjectManager();
|
|
20
19
|
const init = () => ({ value: 0 });
|
|
21
20
|
const behavior = {
|
|
@@ -34,10 +33,12 @@ test('forbid cross-facet prototype attack', async t => {
|
|
|
34
33
|
thing2.mutable.set(2);
|
|
35
34
|
|
|
36
35
|
t.throws(() => attack1(thing1.mutable, thing2.immutable), {
|
|
37
|
-
message:
|
|
36
|
+
message:
|
|
37
|
+
'"In \\"set\\" method of (thing mutable)" may only be applied to a valid instance: "[Alleged: thing immutable]"',
|
|
38
38
|
});
|
|
39
39
|
t.throws(() => attack2(thing1.mutable, thing2.immutable), {
|
|
40
|
-
message:
|
|
40
|
+
message:
|
|
41
|
+
'"In \\"set\\" method of (thing mutable)" may only be applied to a valid instance: "[Alleged: thing immutable]"',
|
|
41
42
|
});
|
|
42
43
|
t.is(thing1.immutable.get(), 1);
|
|
43
44
|
t.is(thing2.immutable.get(), 2);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
4
3
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
4
|
|
|
6
|
-
test('non-object initial data message',
|
|
5
|
+
test('non-object initial data message', t => {
|
|
7
6
|
const vom = makeFakeVirtualObjectManager();
|
|
8
7
|
const goodInit = () => ({ value: 0 });
|
|
9
8
|
// 'badInit' is () => { value: 0 }
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
4
3
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
4
|
|
|
6
|
-
test('facets',
|
|
5
|
+
test('facets', t => {
|
|
7
6
|
const vom = makeFakeVirtualObjectManager();
|
|
8
7
|
const init = () => ({ value: 0 });
|
|
9
8
|
const behavior = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
import { Far } from '@endo/marshal';
|
|
4
|
+
import { kser } from '@agoric/kmarshal';
|
|
4
5
|
import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js';
|
|
5
6
|
import { makeLiveSlots } from '../../src/liveslots.js';
|
|
6
7
|
import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
7
|
-
import { kser } from '../kmarshal.js';
|
|
8
8
|
import { buildSyscall } from '../liveslots-helpers.js';
|
|
9
9
|
import { makeStartVat, makeMessage } from '../util.js';
|
|
10
10
|
import { makeMockGC } from '../mock-gc.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { Remotable } from '@endo/marshal';
|
|
5
5
|
import { initEmpty } from '@agoric/store';
|
|
@@ -7,7 +7,7 @@ import { initEmpty } from '@agoric/store';
|
|
|
7
7
|
import { makeVatSlot } from '../../src/parseVatSlots.js';
|
|
8
8
|
import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js';
|
|
9
9
|
|
|
10
|
-
test('VOM tracks reachable vrefs',
|
|
10
|
+
test('VOM tracks reachable vrefs', t => {
|
|
11
11
|
const { vom, vrm, cm } = makeFakeVirtualStuff();
|
|
12
12
|
const { defineKind } = vom;
|
|
13
13
|
const { makeScalarBigWeakMapStore } = cm;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
// this sets process.env.DEBUG = 'label-instances'
|
|
4
3
|
import './set-debug-label-instances.js';
|
|
5
4
|
|
|
6
5
|
import { passStyleOf } from '@endo/far';
|
|
7
6
|
|
|
8
7
|
// this samples it
|
|
8
|
+
import { q } from '@endo/errors';
|
|
9
9
|
import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js';
|
|
10
10
|
// all tests in this file will be run with DEBUG='label-instances'
|
|
11
11
|
import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
12
12
|
|
|
13
|
-
const { quote: q } = assert;
|
|
14
|
-
|
|
15
13
|
const init = () => ({});
|
|
16
14
|
const behavior = {};
|
|
17
15
|
const facets = { foo: {}, bar: {} };
|
|
18
16
|
|
|
19
|
-
test('representatives with label-instances',
|
|
17
|
+
test('representatives with label-instances', t => {
|
|
20
18
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
21
19
|
const { getSlotForVal } = fakeStuff;
|
|
22
20
|
const makeThing = vom.defineKind('thing', init, behavior);
|
|
@@ -33,7 +31,7 @@ test('representatives with label-instances', async t => {
|
|
|
33
31
|
t.is(`${q(thing2)}`, `"[Alleged: thing#${thing2vref}]"`);
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
test('facets with label-instances',
|
|
34
|
+
test('facets with label-instances', t => {
|
|
37
35
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
38
36
|
const { getSlotForVal } = fakeStuff;
|
|
39
37
|
const makeThings = vom.defineKindMulti('thing', init, facets);
|