@agoric/swingset-liveslots 0.10.3-dev-eb7e9eb.0 → 0.10.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 +61 -0
- package/package.json +19 -18
- package/src/collectionManager.js +41 -112
- package/src/index.js +1 -2
- package/src/liveslots.js +73 -46
- package/src/virtualObjectManager.js +13 -22
- package/src/virtualReferences.js +0 -51
- package/test/liveslots-helpers.js +4 -4
- package/test/mock-gc.js +0 -1
- package/test/storeGC/test-lifecycle.js +0 -1
- package/test/test-collection-upgrade.js +1 -0
- package/test/test-collections.js +13 -103
- package/test/test-durabilityChecks.js +2 -2
- package/test/test-facetiousness.js +1 -1
- package/test/test-gc-sensitivity.js +0 -1
- package/test/test-handled-promises.js +5 -4
- package/test/test-initial-vrefs.js +1 -1
- package/test/test-liveslots-mock-gc.js +0 -1
- package/test/test-liveslots-real-gc.js +0 -1
- package/test/test-liveslots.js +12 -12
- package/test/test-vpid-liveslots.js +1 -1
- package/test/util.js +1 -1
- package/test/virtual-objects/test-cease-recognition.js +1 -2
- package/test/virtual-objects/test-cross-facet.js +1 -1
- package/test/virtual-objects/test-empty-data.js +1 -1
- package/test/virtual-objects/test-facets.js +1 -1
- package/test/virtual-objects/test-kind-changes.js +0 -1
- package/test/virtual-objects/test-reachable-vrefs.js +1 -2
- package/test/virtual-objects/test-rep-tostring.js +2 -2
- package/test/virtual-objects/test-retain-remotable.js +0 -1
- package/test/virtual-objects/test-state-shape.js +0 -1
- package/test/virtual-objects/test-virtualObjectGC.js +0 -1
- package/test/virtual-objects/test-virtualObjectManager.js +0 -5
- package/test/virtual-objects/test-vo-real-gc.js +0 -1
- package/test/virtual-objects/test-weakcollections-vref-handling.js +1 -1
- package/src/vatDataTypes.d.ts +0 -206
- package/src/vatDataTypes.js +0 -2
- package/tools/fakeCollectionManager.js +0 -44
- package/tools/fakeVirtualObjectManager.js +0 -60
- package/tools/fakeVirtualSupport.js +0 -375
- package/tools/prepare-test-env.js +0 -14
- package/tools/setup-vat-data.js +0 -54
- package/tools/vo-test-harness.js +0 -143
|
@@ -16,19 +16,10 @@ import {
|
|
|
16
16
|
|
|
17
17
|
/** @template T @typedef {import('@agoric/vat-data').DefineKindOptions<T>} DefineKindOptions */
|
|
18
18
|
|
|
19
|
-
const { hasOwn, defineProperty, getOwnPropertyNames
|
|
19
|
+
const { hasOwn, defineProperty, getOwnPropertyNames } = Object;
|
|
20
20
|
const { ownKeys } = Reflect;
|
|
21
21
|
const { quote: q } = assert;
|
|
22
22
|
|
|
23
|
-
// See https://github.com/Agoric/agoric-sdk/issues/8005
|
|
24
|
-
// Once agoric-sdk is upgraded to depend on endo post
|
|
25
|
-
// https://github.com/endojs/endo/pull/1606 then remove this
|
|
26
|
-
// definition of `b` and say instead
|
|
27
|
-
// ```js
|
|
28
|
-
// const { quote: q, base: b } = assert;
|
|
29
|
-
// ```
|
|
30
|
-
const b = index => q(Number(index));
|
|
31
|
-
|
|
32
23
|
// import { kdebug } from './kdebug.js';
|
|
33
24
|
|
|
34
25
|
// TODO Use environment-options.js currently in ses/src after factoring it out
|
|
@@ -150,8 +141,9 @@ const makeContextCache = (makeState, makeContext) => {
|
|
|
150
141
|
* @param {*} getSlotForVal
|
|
151
142
|
* @returns {ContextProvider}
|
|
152
143
|
*/
|
|
153
|
-
const makeContextProvider = (contextCache, getSlotForVal) =>
|
|
154
|
-
harden(rep => contextCache.get(getSlotForVal(rep)));
|
|
144
|
+
const makeContextProvider = (contextCache, getSlotForVal) => {
|
|
145
|
+
return harden(rep => contextCache.get(getSlotForVal(rep)));
|
|
146
|
+
};
|
|
155
147
|
|
|
156
148
|
const makeContextProviderKit = (contextCache, getSlotForVal, facetNames) => {
|
|
157
149
|
/** @type { Record<string, any> } */
|
|
@@ -268,15 +260,15 @@ const makeFacets = (
|
|
|
268
260
|
};
|
|
269
261
|
|
|
270
262
|
const insistDurableCapdata = (vrm, what, capdata, valueFor) => {
|
|
271
|
-
|
|
263
|
+
capdata.slots.forEach((vref, idx) => {
|
|
272
264
|
if (!vrm.isDurable(vref)) {
|
|
273
265
|
if (valueFor) {
|
|
274
|
-
Fail`value for ${what} is not durable: slot ${
|
|
266
|
+
Fail`value for ${what} is not durable: slot ${q(idx)} of ${capdata}`;
|
|
275
267
|
} else {
|
|
276
|
-
Fail`${what} is not durable: slot ${
|
|
268
|
+
Fail`${what} is not durable: slot ${q(idx)} of ${capdata}`;
|
|
277
269
|
}
|
|
278
270
|
}
|
|
279
|
-
}
|
|
271
|
+
});
|
|
280
272
|
};
|
|
281
273
|
|
|
282
274
|
const insistSameCapData = (oldCD, newCD) => {
|
|
@@ -289,11 +281,11 @@ const insistSameCapData = (oldCD, newCD) => {
|
|
|
289
281
|
if (oldCD.slots.length !== newCD.slots.length) {
|
|
290
282
|
Fail`durable Kind stateShape mismatch (slots.length)`;
|
|
291
283
|
}
|
|
292
|
-
|
|
284
|
+
oldCD.slots.forEach((oldVref, idx) => {
|
|
293
285
|
if (newCD.slots[idx] !== oldVref) {
|
|
294
286
|
Fail`durable Kind stateShape mismatch (slot[${idx}])`;
|
|
295
287
|
}
|
|
296
|
-
}
|
|
288
|
+
});
|
|
297
289
|
};
|
|
298
290
|
|
|
299
291
|
/**
|
|
@@ -715,7 +707,7 @@ export const makeVirtualObjectManager = (
|
|
|
715
707
|
durableKindDescriptor = undefined, // only for durables
|
|
716
708
|
) => {
|
|
717
709
|
const {
|
|
718
|
-
finish
|
|
710
|
+
finish,
|
|
719
711
|
stateShape = undefined,
|
|
720
712
|
thisfulMethods = false,
|
|
721
713
|
interfaceGuard = undefined,
|
|
@@ -982,9 +974,9 @@ export const makeVirtualObjectManager = (
|
|
|
982
974
|
let doMoreGC = false;
|
|
983
975
|
const record = dataCache.get(baseRef);
|
|
984
976
|
for (const valueCD of Object.values(record.capdatas)) {
|
|
985
|
-
|
|
977
|
+
valueCD.slots.forEach(vref => {
|
|
986
978
|
doMoreGC = vrm.removeReachableVref(vref) || doMoreGC;
|
|
987
|
-
}
|
|
979
|
+
});
|
|
988
980
|
}
|
|
989
981
|
dataCache.delete(baseRef);
|
|
990
982
|
return doMoreGC;
|
|
@@ -1023,7 +1015,6 @@ export const makeVirtualObjectManager = (
|
|
|
1023
1015
|
if (isDurable) {
|
|
1024
1016
|
insistDurableCapdata(vrm, prop, valueCD, true);
|
|
1025
1017
|
}
|
|
1026
|
-
// eslint-disable-next-line github/array-foreach
|
|
1027
1018
|
valueCD.slots.forEach(vrm.addReachableVref);
|
|
1028
1019
|
capdatas[prop] = valueCD;
|
|
1029
1020
|
valueMap.set(prop, value);
|
package/src/virtualReferences.js
CHANGED
|
@@ -682,54 +682,6 @@ export function makeVirtualReferenceManager(
|
|
|
682
682
|
return size;
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
-
/**
|
|
686
|
-
* Counters to track the next number for various categories of allocation.
|
|
687
|
-
* `exportID` starts at 1 because 'o+0' is always automatically
|
|
688
|
-
* pre-assigned to the root object.
|
|
689
|
-
* `promiseID` starts at 5 as a very minor aid to debugging: when puzzling
|
|
690
|
-
* over trace logs and the like, it helps for the numbers in various species
|
|
691
|
-
* of IDs that are jumbled together to be a little out of sync and thus a
|
|
692
|
-
* little less similar to each other.
|
|
693
|
-
*/
|
|
694
|
-
const initialIDCounters = { exportID: 1, collectionID: 1, promiseID: 5 };
|
|
695
|
-
/** @type {Record<string, number>} */
|
|
696
|
-
let idCounters;
|
|
697
|
-
let idCountersAreDirty = false;
|
|
698
|
-
|
|
699
|
-
function initializeIDCounters() {
|
|
700
|
-
if (!idCounters) {
|
|
701
|
-
// the saved value might be missing, or from an older liveslots
|
|
702
|
-
// (with fewer counters), so merge it with our initial values
|
|
703
|
-
const saved = JSON.parse(syscall.vatstoreGet('idCounters') || '{}');
|
|
704
|
-
idCounters = { ...initialIDCounters, ...saved };
|
|
705
|
-
idCountersAreDirty = true;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
function allocateNextID(name) {
|
|
710
|
-
if (!idCounters) {
|
|
711
|
-
// Normally `initializeIDCounters` would be called from startVat, but some
|
|
712
|
-
// tests bypass that so this is a backstop. Note that the invocation from
|
|
713
|
-
// startVat is there to make vatStore access patterns a bit more
|
|
714
|
-
// consistent from one vat to another, principally as a confusion
|
|
715
|
-
// reduction measure in service of debugging; it is not a correctness
|
|
716
|
-
// issue.
|
|
717
|
-
initializeIDCounters();
|
|
718
|
-
}
|
|
719
|
-
const result = idCounters[name];
|
|
720
|
-
result !== undefined || Fail`unknown idCounters[${name}]`;
|
|
721
|
-
idCounters[name] += 1;
|
|
722
|
-
idCountersAreDirty = true;
|
|
723
|
-
return result;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
function flushIDCounters() {
|
|
727
|
-
if (idCountersAreDirty) {
|
|
728
|
-
syscall.vatstoreSet('idCounters', JSON.stringify(idCounters));
|
|
729
|
-
idCountersAreDirty = false;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
685
|
const testHooks = {
|
|
734
686
|
getReachableRefCount,
|
|
735
687
|
countCollectionsForWeakKey,
|
|
@@ -774,9 +726,6 @@ export function makeVirtualReferenceManager(
|
|
|
774
726
|
ceaseRecognition,
|
|
775
727
|
setDeleteCollectionEntry,
|
|
776
728
|
getRetentionStats,
|
|
777
|
-
initializeIDCounters,
|
|
778
|
-
allocateNextID,
|
|
779
|
-
flushIDCounters,
|
|
780
729
|
testHooks,
|
|
781
730
|
});
|
|
782
731
|
}
|
|
@@ -16,8 +16,8 @@ import { kser } from './kmarshal.js';
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @param {object} [options]
|
|
19
|
-
* @param {boolean} [options.skipLogging]
|
|
20
|
-
* @param {Map<string, string>} [options.kvStore]
|
|
19
|
+
* @param {boolean} [options.skipLogging = false]
|
|
20
|
+
* @param {Map<string, string>} [options.kvStore = new Map()]
|
|
21
21
|
*/
|
|
22
22
|
export function buildSyscall(options = {}) {
|
|
23
23
|
const { skipLogging = false, kvStore: fakestore = new Map() } = options;
|
|
@@ -168,9 +168,9 @@ function makeRPMaker(nextNumber = 1) {
|
|
|
168
168
|
* @param {string} vatName
|
|
169
169
|
* @param {object} [options]
|
|
170
170
|
* @param {boolean} [options.forceGC]
|
|
171
|
-
* @param {Map<string, string>} [options.kvStore]
|
|
171
|
+
* @param {Map<string, string>} [options.kvStore = new Map()]
|
|
172
172
|
* @param {number} [options.nextPromiseImportNumber]
|
|
173
|
-
* @param {boolean} [options.skipLogging]
|
|
173
|
+
* @param {boolean} [options.skipLogging = false]
|
|
174
174
|
*/
|
|
175
175
|
export async function setupTestLiveslots(
|
|
176
176
|
t,
|
package/test/mock-gc.js
CHANGED
package/test/test-collections.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
3
2
|
import '@endo/init/debug.js';
|
|
4
3
|
|
|
5
4
|
import { Far } from '@endo/marshal';
|
|
6
5
|
import { M } from '@agoric/store';
|
|
7
|
-
import { makeCopyMap, makeCopySet } from '@endo/patterns';
|
|
8
6
|
import { makeFakeCollectionManager } from '../tools/fakeVirtualSupport.js';
|
|
9
7
|
|
|
10
8
|
const {
|
|
@@ -193,89 +191,6 @@ test('basic weak set operations', t => {
|
|
|
193
191
|
);
|
|
194
192
|
});
|
|
195
193
|
|
|
196
|
-
function exerciseSetAddAll(t, weak, testStore) {
|
|
197
|
-
const allThatStuff = stuff.map(entry => entry[0]);
|
|
198
|
-
|
|
199
|
-
testStore.addAll(allThatStuff);
|
|
200
|
-
for (const elem of allThatStuff) {
|
|
201
|
-
t.truthy(testStore.has(elem));
|
|
202
|
-
testStore.delete(elem);
|
|
203
|
-
}
|
|
204
|
-
if (!weak) {
|
|
205
|
-
t.is(testStore.getSize(), 0);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
testStore.addAll(makeCopySet(allThatStuff));
|
|
209
|
-
for (const elem of allThatStuff) {
|
|
210
|
-
t.truthy(testStore.has(elem));
|
|
211
|
-
testStore.delete(elem);
|
|
212
|
-
}
|
|
213
|
-
if (!weak) {
|
|
214
|
-
t.is(testStore.getSize(), 0);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
t.throws(
|
|
218
|
-
() => testStore.addAll({ bogus: 47 }),
|
|
219
|
-
m(/provided data source is not iterable/),
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
test('set addAll', t => {
|
|
224
|
-
exerciseSetAddAll(t, false, makeScalarBigSetStore('test set'));
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test('weak set addAll', t => {
|
|
228
|
-
exerciseSetAddAll(t, true, makeScalarBigWeakSetStore('test weak set'));
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test('set snapshot', t => {
|
|
232
|
-
const testStore = makeScalarBigSetStore('test set');
|
|
233
|
-
const allThatStuff = stuff.map(entry => entry[0]);
|
|
234
|
-
testStore.addAll(allThatStuff);
|
|
235
|
-
t.deepEqual(testStore.snapshot(), makeCopySet(allThatStuff));
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
function exerciseMapAddAll(t, weak, testStore) {
|
|
239
|
-
testStore.addAll(stuff);
|
|
240
|
-
for (const [k, v] of stuff) {
|
|
241
|
-
t.truthy(testStore.has(k));
|
|
242
|
-
t.is(testStore.get(k), v);
|
|
243
|
-
testStore.delete(k);
|
|
244
|
-
}
|
|
245
|
-
if (!weak) {
|
|
246
|
-
t.is(testStore.getSize(), 0);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
testStore.addAll(makeCopyMap(stuff));
|
|
250
|
-
for (const [k, v] of stuff) {
|
|
251
|
-
t.truthy(testStore.has(k));
|
|
252
|
-
t.is(testStore.get(k), v);
|
|
253
|
-
testStore.delete(k);
|
|
254
|
-
}
|
|
255
|
-
if (!weak) {
|
|
256
|
-
t.is(testStore.getSize(), 0);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
t.throws(
|
|
260
|
-
() => testStore.addAll({ bogus: 47 }),
|
|
261
|
-
m(/provided data source is not iterable/),
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
test('map addAll', t => {
|
|
266
|
-
exerciseMapAddAll(t, false, makeScalarBigMapStore('test map'));
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test('weak map addAll', t => {
|
|
270
|
-
exerciseMapAddAll(t, true, makeScalarBigWeakMapStore('test weak map'));
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
test('map snapshot', t => {
|
|
274
|
-
const testStore = makeScalarBigMapStore('test map');
|
|
275
|
-
testStore.addAll(stuff);
|
|
276
|
-
t.deepEqual(testStore.snapshot(), makeCopyMap(stuff));
|
|
277
|
-
});
|
|
278
|
-
|
|
279
194
|
test('constrain map key shape', t => {
|
|
280
195
|
const stringsOnly = makeScalarBigMapStore('map key strings only', {
|
|
281
196
|
keyShape: M.string(),
|
|
@@ -490,9 +405,7 @@ test('map fail on concurrent modification', t => {
|
|
|
490
405
|
const primeMap = makeScalarBigMapStore('fmap', {
|
|
491
406
|
keyShape: M.number(),
|
|
492
407
|
});
|
|
493
|
-
|
|
494
|
-
primeMap.init(v, `${v} is prime #${i + 1}`);
|
|
495
|
-
}
|
|
408
|
+
primes.forEach((v, i) => primeMap.init(v, `${v} is prime #${i + 1}`));
|
|
496
409
|
|
|
497
410
|
let iter = primeMap.keys()[Symbol.iterator]();
|
|
498
411
|
t.deepEqual(iter.next(), { done: false, value: 2 });
|
|
@@ -520,9 +433,7 @@ test('set fail on concurrent modification', t => {
|
|
|
520
433
|
const primeSet = makeScalarBigSetStore('fset', {
|
|
521
434
|
keyShape: M.number(),
|
|
522
435
|
});
|
|
523
|
-
|
|
524
|
-
primeSet.add(v);
|
|
525
|
-
}
|
|
436
|
+
primes.forEach(v => primeSet.add(v));
|
|
526
437
|
|
|
527
438
|
let iter = primeSet.keys()[Symbol.iterator]();
|
|
528
439
|
t.deepEqual(iter.next(), { done: false, value: 2 });
|
|
@@ -550,9 +461,7 @@ test('map ok with concurrent deletion', t => {
|
|
|
550
461
|
const primeMap = makeScalarBigMapStore('fmap', {
|
|
551
462
|
keyShape: M.number(),
|
|
552
463
|
});
|
|
553
|
-
|
|
554
|
-
primeMap.init(v, `${v} is prime #${i + 1}`);
|
|
555
|
-
}
|
|
464
|
+
primes.forEach((v, i) => primeMap.init(v, `${v} is prime #${i + 1}`));
|
|
556
465
|
const iter = primeMap.keys()[Symbol.iterator]();
|
|
557
466
|
t.deepEqual(iter.next(), { done: false, value: 2 });
|
|
558
467
|
primeMap.delete(3);
|
|
@@ -567,9 +476,7 @@ test('set ok with concurrent deletion', t => {
|
|
|
567
476
|
const primeSet = makeScalarBigSetStore('fset', {
|
|
568
477
|
keyShape: M.number(),
|
|
569
478
|
});
|
|
570
|
-
|
|
571
|
-
primeSet.add(v);
|
|
572
|
-
}
|
|
479
|
+
primes.forEach(v => primeSet.add(v));
|
|
573
480
|
|
|
574
481
|
const iter = primeSet.keys()[Symbol.iterator]();
|
|
575
482
|
t.deepEqual(iter.next(), { done: false, value: 2 });
|
|
@@ -859,6 +766,13 @@ test('set queries', t => {
|
|
|
859
766
|
symbolKrusty,
|
|
860
767
|
undefined,
|
|
861
768
|
]);
|
|
769
|
+
|
|
770
|
+
// @ts-expect-error our BigSetStore has .entries, but not the SetStore type
|
|
771
|
+
t.deepEqual(Array.from(testStore.entries(M.number())), [
|
|
772
|
+
[-29, -29],
|
|
773
|
+
[3, 3],
|
|
774
|
+
[47, 47],
|
|
775
|
+
]);
|
|
862
776
|
});
|
|
863
777
|
|
|
864
778
|
test('remotable sort order', t => {
|
|
@@ -884,9 +798,7 @@ test('complex map queries', t => {
|
|
|
884
798
|
const primeStore = makeScalarBigMapStore('prime map', {
|
|
885
799
|
keyShape: M.number(),
|
|
886
800
|
});
|
|
887
|
-
|
|
888
|
-
primeStore.init(v, `${v} is prime #${i + 1}`);
|
|
889
|
-
}
|
|
801
|
+
primes.forEach((v, i) => primeStore.init(v, `${v} is prime #${i + 1}`));
|
|
890
802
|
|
|
891
803
|
t.deepEqual(Array.from(primeStore.values()), [
|
|
892
804
|
'2 is prime #1',
|
|
@@ -1061,9 +973,7 @@ test('complex set queries', t => {
|
|
|
1061
973
|
const primeStore = makeScalarBigSetStore('prime set', {
|
|
1062
974
|
keyShape: M.number(),
|
|
1063
975
|
});
|
|
1064
|
-
|
|
1065
|
-
primeStore.add(v);
|
|
1066
|
-
}
|
|
976
|
+
primes.forEach(v => primeStore.add(v));
|
|
1067
977
|
|
|
1068
978
|
t.deepEqual(
|
|
1069
979
|
Array.from(primeStore.values()),
|
|
@@ -269,5 +269,5 @@ async function runDurabilityCheckTest(t, relaxDurabilityRules) {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
test('durability checks (strict)', runDurabilityCheckTest, false);
|
|
273
|
-
test('durability checks (relaxed)', runDurabilityCheckTest, true);
|
|
272
|
+
test('durability checks (strict)', t => runDurabilityCheckTest(t, false));
|
|
273
|
+
test('durability checks (relaxed)', t => runDurabilityCheckTest(t, true));
|
|
@@ -126,7 +126,7 @@ test('checkAndUpdateFacetiousness', t => {
|
|
|
126
126
|
t.deepEqual(cauf({}, barfoo), barfoo);
|
|
127
127
|
|
|
128
128
|
// a single Kind can only be redefined as another single
|
|
129
|
-
t.
|
|
129
|
+
t.deepEqual(cauf(desc(), undefined), undefined);
|
|
130
130
|
t.throws(() => cauf(desc(), foo), {
|
|
131
131
|
message: 'defineDurableKindMulti called for unfaceted KindHandle "tag"',
|
|
132
132
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop, @jessie.js/no-nested-await, no-shadow */
|
|
1
2
|
import test from 'ava';
|
|
2
3
|
import '@endo/init/debug.js';
|
|
3
4
|
|
|
@@ -232,12 +233,12 @@ test('past-incarnation watched promises', async t => {
|
|
|
232
233
|
t.deepEqual(getDispatchLogs(), [
|
|
233
234
|
fulfillmentMessage(`p-${nextPImport()}`, 'created local promise: rejected'),
|
|
234
235
|
]);
|
|
235
|
-
t.
|
|
236
|
+
t.deepEqual(
|
|
236
237
|
lastPImport - firstPImport + 1,
|
|
237
238
|
4,
|
|
238
239
|
'imported 4 promises (1 per dispatch)',
|
|
239
240
|
);
|
|
240
|
-
t.
|
|
241
|
+
t.deepEqual(lastPExport - firstPExport + 1, 1, 'exported 1 promise: first');
|
|
241
242
|
|
|
242
243
|
await dispatchMessage('watchLocalPromise', 'orphaned');
|
|
243
244
|
t.deepEqual(getDispatchLogs(), [
|
|
@@ -259,12 +260,12 @@ test('past-incarnation watched promises', async t => {
|
|
|
259
260
|
fulfillmentMessage(`p-${nextPImport()}`, 'watched local promise: rejected'),
|
|
260
261
|
rejectionMessage(`p+${lastPExport}`, S),
|
|
261
262
|
]);
|
|
262
|
-
t.
|
|
263
|
+
t.deepEqual(
|
|
263
264
|
lastPImport - firstPImport + 1,
|
|
264
265
|
7,
|
|
265
266
|
'imported 7 promises (1 per dispatch)',
|
|
266
267
|
);
|
|
267
|
-
t.
|
|
268
|
+
t.deepEqual(
|
|
268
269
|
lastPExport - firstPExport + 1,
|
|
269
270
|
4,
|
|
270
271
|
'exported 4 promises: first, orphaned, fulfilled, rejected',
|
|
@@ -148,5 +148,5 @@ test('vrefs', async t => {
|
|
|
148
148
|
const expectedStore1Vref = `o+v${initialKindIDs.scalarMapStore}/5`;
|
|
149
149
|
const store1Vref = (await run('getStore1')).slots[0];
|
|
150
150
|
t.is(store1Vref, expectedStore1Vref);
|
|
151
|
-
t.
|
|
151
|
+
t.deepEqual(kunser(JSON.parse(fakestore.get(`vc.5.s${'key'}`))), 'value');
|
|
152
152
|
});
|
package/test/test-liveslots.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
3
2
|
import '@endo/init/debug.js';
|
|
4
3
|
|
|
@@ -46,14 +45,14 @@ test('calls', async t => {
|
|
|
46
45
|
|
|
47
46
|
// root!one() // sendOnly
|
|
48
47
|
await dispatch(makeMessage(rootA, 'one', ['args']));
|
|
49
|
-
t.
|
|
48
|
+
t.deepEqual(log.shift(), 'one');
|
|
50
49
|
|
|
51
50
|
// pr = makePromise()
|
|
52
51
|
// root!two(pr.promise)
|
|
53
52
|
// pr.resolve('result')
|
|
54
53
|
await dispatch(makeMessage(rootA, 'two', [kslot('p-1')]));
|
|
55
54
|
t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-1' });
|
|
56
|
-
t.
|
|
55
|
+
t.deepEqual(log.shift(), 'two true');
|
|
57
56
|
|
|
58
57
|
await dispatch(makeResolve('p-1', kser('result')));
|
|
59
58
|
t.deepEqual(log.shift(), ['res', 'result']);
|
|
@@ -64,7 +63,7 @@ test('calls', async t => {
|
|
|
64
63
|
|
|
65
64
|
await dispatch(makeMessage(rootA, 'two', [kslot('p-2')]));
|
|
66
65
|
t.deepEqual(log.shift(), { type: 'subscribe', target: 'p-2' });
|
|
67
|
-
t.
|
|
66
|
+
t.deepEqual(log.shift(), 'two true');
|
|
68
67
|
|
|
69
68
|
await dispatch(makeReject('p-2', kser('rejection')));
|
|
70
69
|
t.deepEqual(log.shift(), ['rej', 'rejection']);
|
|
@@ -100,7 +99,7 @@ test('liveslots pipelines to syscall.send', async t => {
|
|
|
100
99
|
// for x!pipe1(), a second pipelined to the result promise of it, and a
|
|
101
100
|
// third pipelined to the result of the second.
|
|
102
101
|
|
|
103
|
-
t.
|
|
102
|
+
t.deepEqual(log.shift(), 'sent p1p2p3');
|
|
104
103
|
t.deepEqual(log.shift(), {
|
|
105
104
|
type: 'send',
|
|
106
105
|
targetSlot: x,
|
|
@@ -657,7 +656,8 @@ test('capdata size limit on syscalls', async t => {
|
|
|
657
656
|
};
|
|
658
657
|
|
|
659
658
|
const send = op => dispatch(makeMessage(rootA, op, [kslot(target)], rp));
|
|
660
|
-
const expectFail = () =>
|
|
659
|
+
const expectFail = () =>
|
|
660
|
+
t.deepEqual(log.shift(), 'fail: syscall capdata too large');
|
|
661
661
|
const expectVoidReturn = () =>
|
|
662
662
|
t.deepEqual(log.shift(), {
|
|
663
663
|
type: 'resolve',
|
|
@@ -906,7 +906,7 @@ test('disable disavow', async t => {
|
|
|
906
906
|
|
|
907
907
|
// root~.one() // sendOnly
|
|
908
908
|
await dispatch(makeMessage(rootA, 'one', []));
|
|
909
|
-
t.
|
|
909
|
+
t.deepEqual(log.shift(), false);
|
|
910
910
|
t.deepEqual(log, []);
|
|
911
911
|
});
|
|
912
912
|
|
|
@@ -967,7 +967,7 @@ test('disavow', async t => {
|
|
|
967
967
|
// root~.one(import1) // sendOnly
|
|
968
968
|
await dispatch(makeMessage(rootA, 'one', [kslot(import1)]));
|
|
969
969
|
t.deepEqual(log.shift(), { type: 'dropImports', slots: [import1] });
|
|
970
|
-
t.
|
|
970
|
+
t.deepEqual(log.shift(), 'disavowed pres1');
|
|
971
971
|
|
|
972
972
|
function loggedError(re) {
|
|
973
973
|
const l = log.shift();
|
|
@@ -975,11 +975,11 @@ test('disavow', async t => {
|
|
|
975
975
|
t.truthy(re.test(l.message));
|
|
976
976
|
}
|
|
977
977
|
loggedError(/attempt to disavow unknown/);
|
|
978
|
-
t.
|
|
978
|
+
t.deepEqual(log.shift(), 'tried duplicate disavow');
|
|
979
979
|
loggedError(/attempt to disavow unknown/);
|
|
980
|
-
t.
|
|
980
|
+
t.deepEqual(log.shift(), 'tried to disavow Promise');
|
|
981
981
|
loggedError(/attempt to disavow an export/);
|
|
982
|
-
t.
|
|
982
|
+
t.deepEqual(log.shift(), 'tried to disavow export');
|
|
983
983
|
const msg = log.shift();
|
|
984
984
|
t.like(msg, {
|
|
985
985
|
type: 'exit',
|
|
@@ -987,7 +987,7 @@ test('disavow', async t => {
|
|
|
987
987
|
});
|
|
988
988
|
expectError(t, msg.info, /this Presence has been disavowed/);
|
|
989
989
|
t.deepEqual(log.shift(), Error('this Presence has been disavowed'));
|
|
990
|
-
t.
|
|
990
|
+
t.deepEqual(log.shift(), 'tried to send to disavowed');
|
|
991
991
|
t.deepEqual(log, []);
|
|
992
992
|
});
|
|
993
993
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
3
2
|
import '@endo/init/debug.js';
|
|
4
3
|
|
|
@@ -294,6 +293,7 @@ async function doVatResolveCase23(t, which, mode, stalls) {
|
|
|
294
293
|
// another few turns. We wait some number of turns before using p1
|
|
295
294
|
// again, to exercise as many race conditions as possible.
|
|
296
295
|
for (let i = 0; i < stalls; i += 1) {
|
|
296
|
+
// eslint-disable-next-line no-await-in-loop
|
|
297
297
|
await Promise.resolve();
|
|
298
298
|
}
|
|
299
299
|
|
package/test/util.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/* global FinalizationRegistry WeakRef */
|
|
3
2
|
import test from 'ava';
|
|
4
3
|
import '@endo/init/debug.js';
|
|
@@ -39,7 +38,7 @@ function weakKeyCheck(t, log, vref) {
|
|
|
39
38
|
t.true(result === undefined || !result.startsWith(prefix), `ew:${result}`);
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
test('only enumerate virtual objects', t => {
|
|
41
|
+
test('only enumerate virtual objects', async t => {
|
|
43
42
|
const { log, vrm } = makeVRM();
|
|
44
43
|
|
|
45
44
|
// retiring a plain Remotable does a is-it-a-weak-key chck
|
|
@@ -15,7 +15,7 @@ function attack2(mut1, immut2) {
|
|
|
15
15
|
Reflect.apply(mutableProto.set, immut2, [6]);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
test('forbid cross-facet prototype attack', t => {
|
|
18
|
+
test('forbid cross-facet prototype attack', async t => {
|
|
19
19
|
const vom = makeFakeVirtualObjectManager();
|
|
20
20
|
const init = () => ({ value: 0 });
|
|
21
21
|
const behavior = {
|
|
@@ -3,7 +3,7 @@ import '@endo/init/debug.js';
|
|
|
3
3
|
|
|
4
4
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
5
|
|
|
6
|
-
test('non-object initial data message', t => {
|
|
6
|
+
test('non-object initial data message', async t => {
|
|
7
7
|
const vom = makeFakeVirtualObjectManager();
|
|
8
8
|
const goodInit = () => ({ value: 0 });
|
|
9
9
|
// 'badInit' is () => { value: 0 }
|
|
@@ -3,7 +3,7 @@ import '@endo/init/debug.js';
|
|
|
3
3
|
|
|
4
4
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
5
|
|
|
6
|
-
test('facets', t => {
|
|
6
|
+
test('facets', async t => {
|
|
7
7
|
const vom = makeFakeVirtualObjectManager();
|
|
8
8
|
const init = () => ({ value: 0 });
|
|
9
9
|
const behavior = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import test from 'ava';
|
|
3
2
|
import '@endo/init/debug.js';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ import { initEmpty } from '@agoric/store';
|
|
|
8
7
|
import { makeVatSlot } from '../../src/parseVatSlots.js';
|
|
9
8
|
import { makeFakeVirtualStuff } from '../../tools/fakeVirtualSupport.js';
|
|
10
9
|
|
|
11
|
-
test('VOM tracks reachable vrefs', t => {
|
|
10
|
+
test('VOM tracks reachable vrefs', async t => {
|
|
12
11
|
const { vom, vrm, cm } = makeFakeVirtualStuff();
|
|
13
12
|
const { defineKind } = vom;
|
|
14
13
|
const { makeScalarBigWeakMapStore } = cm;
|
|
@@ -16,7 +16,7 @@ const init = () => ({});
|
|
|
16
16
|
const behavior = {};
|
|
17
17
|
const facets = { foo: {}, bar: {} };
|
|
18
18
|
|
|
19
|
-
test('representatives with label-instances', t => {
|
|
19
|
+
test('representatives with label-instances', async t => {
|
|
20
20
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
21
21
|
const { getSlotForVal } = fakeStuff;
|
|
22
22
|
const makeThing = vom.defineKind('thing', init, behavior);
|
|
@@ -33,7 +33,7 @@ test('representatives with label-instances', t => {
|
|
|
33
33
|
t.is(`${q(thing2)}`, `"[Alleged: thing#${thing2vref}]"`);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
test('facets with label-instances', t => {
|
|
36
|
+
test('facets with label-instances', async t => {
|
|
37
37
|
const { fakeStuff, vom } = makeFakeVirtualStuff();
|
|
38
38
|
const { getSlotForVal } = fakeStuff;
|
|
39
39
|
const makeThings = vom.defineKindMulti('thing', init, facets);
|