@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.
Files changed (141) hide show
  1. package/README.md +2 -0
  2. package/package.json +34 -26
  3. package/src/boyd-gc.d.ts +12 -0
  4. package/src/boyd-gc.d.ts.map +1 -0
  5. package/src/boyd-gc.js +598 -0
  6. package/src/cache.d.ts +71 -0
  7. package/src/cache.d.ts.map +1 -0
  8. package/src/cache.js +3 -2
  9. package/src/capdata.d.ts +16 -0
  10. package/src/capdata.d.ts.map +1 -0
  11. package/src/capdata.js +17 -10
  12. package/src/collectionManager.d.ts +47 -0
  13. package/src/collectionManager.d.ts.map +1 -0
  14. package/src/collectionManager.js +220 -103
  15. package/src/facetiousness.d.ts +25 -0
  16. package/src/facetiousness.d.ts.map +1 -0
  17. package/src/facetiousness.js +1 -1
  18. package/src/index.d.ts +4 -0
  19. package/src/index.d.ts.map +1 -0
  20. package/src/index.js +4 -2
  21. package/src/kdebug.d.ts +7 -0
  22. package/src/kdebug.d.ts.map +1 -0
  23. package/src/liveslots.d.ts +42 -0
  24. package/src/liveslots.d.ts.map +1 -0
  25. package/src/liveslots.js +137 -305
  26. package/src/message.d.ts +49 -0
  27. package/src/message.d.ts.map +1 -0
  28. package/src/message.js +9 -5
  29. package/src/parseVatSlots.d.ts +125 -0
  30. package/src/parseVatSlots.d.ts.map +1 -0
  31. package/src/parseVatSlots.js +1 -1
  32. package/src/types-index.d.ts +4 -0
  33. package/src/types-index.js +2 -0
  34. package/src/types.d.ts +81 -0
  35. package/src/types.d.ts.map +1 -0
  36. package/src/types.js +14 -7
  37. package/src/vatDataTypes.d.ts +170 -0
  38. package/src/vatDataTypes.d.ts.map +1 -0
  39. package/src/vatDataTypes.ts +272 -0
  40. package/src/vatstore-iterators.d.ts +4 -0
  41. package/src/vatstore-iterators.d.ts.map +1 -0
  42. package/src/vatstore-iterators.js +2 -0
  43. package/src/vatstore-usage.md +198 -0
  44. package/src/virtualObjectManager.d.ts +44 -0
  45. package/src/virtualObjectManager.d.ts.map +1 -0
  46. package/src/virtualObjectManager.js +254 -84
  47. package/src/virtualReferences.d.ts +61 -0
  48. package/src/virtualReferences.d.ts.map +1 -0
  49. package/src/virtualReferences.js +135 -26
  50. package/src/vpid-tracking.md +92 -0
  51. package/src/watchedPromises.d.ts +31 -0
  52. package/src/watchedPromises.d.ts.map +1 -0
  53. package/src/watchedPromises.js +81 -24
  54. package/test/{test-baggage.js → baggage.test.js} +1 -2
  55. package/test/{test-cache.js → cache.test.js} +0 -1
  56. package/test/clear-collection.test.js +586 -0
  57. package/test/{test-collection-schema-refcount.js → collection-schema-refcount.test.js} +1 -2
  58. package/test/{test-collection-upgrade.js → collection-upgrade.test.js} +1 -3
  59. package/test/{test-collections.js → collections.test.js} +183 -18
  60. package/test/{test-dropped-collection-weakrefs.js → dropped-collection-weakrefs.test.js} +1 -2
  61. package/test/dropped-weakset-9939.test.js +80 -0
  62. package/test/dummyMeterControl.d.ts +2 -0
  63. package/test/dummyMeterControl.d.ts.map +1 -0
  64. package/test/dummyMeterControl.js +1 -1
  65. package/test/{test-durabilityChecks.js → durabilityChecks.test.js} +4 -4
  66. package/test/engine-gc.d.ts +3 -0
  67. package/test/engine-gc.d.ts.map +1 -0
  68. package/test/exo-utils.js +70 -0
  69. package/test/{test-facetiousness.js → facetiousness.test.js} +1 -2
  70. package/test/gc-and-finalize.d.ts +5 -0
  71. package/test/gc-and-finalize.d.ts.map +1 -0
  72. package/test/gc-and-finalize.js +30 -1
  73. package/test/gc-before-finalizer.test.js +230 -0
  74. package/test/gc-helpers.js +4 -5
  75. package/test/{test-gc-sensitivity.js → gc-sensitivity.test.js} +2 -2
  76. package/test/handled-promises.test.js +872 -0
  77. package/test/{test-initial-vrefs.js → initial-vrefs.test.js} +13 -20
  78. package/test/liveslots-helpers.d.ts +64 -0
  79. package/test/liveslots-helpers.d.ts.map +1 -0
  80. package/test/liveslots-helpers.js +13 -7
  81. package/test/{test-liveslots-mock-gc.js → liveslots-mock-gc.test.js} +101 -2
  82. package/test/{test-liveslots-real-gc.js → liveslots-real-gc.test.js} +73 -46
  83. package/test/{test-liveslots.js → liveslots.test.js} +17 -18
  84. package/test/mock-gc.js +1 -0
  85. package/test/storeGC/{test-lifecycle.js → lifecycle.test.js} +15 -14
  86. package/test/storeGC/{test-refcount-management.js → refcount-management.test.js} +1 -2
  87. package/test/storeGC/{test-scalar-store-kind.js → scalar-store-kind.test.js} +0 -1
  88. package/test/storeGC/{test-weak-key.js → weak-key.test.js} +1 -2
  89. package/test/strict-test-env-upgrade.test.js +94 -0
  90. package/test/util.d.ts +25 -0
  91. package/test/util.d.ts.map +1 -0
  92. package/test/util.js +4 -4
  93. package/test/vat-environment.test.js +65 -0
  94. package/test/vat-util.d.ts +9 -0
  95. package/test/vat-util.d.ts.map +1 -0
  96. package/test/vat-util.js +2 -2
  97. package/test/virtual-objects/{test-cease-recognition.js → cease-recognition.test.js} +2 -2
  98. package/test/virtual-objects/{test-cross-facet.js → cross-facet.test.js} +5 -4
  99. package/test/virtual-objects/{test-empty-data.js → empty-data.test.js} +1 -2
  100. package/test/virtual-objects/{test-facets.js → facets.test.js} +1 -2
  101. package/test/virtual-objects/{test-kind-changes.js → kind-changes.test.js} +2 -2
  102. package/test/virtual-objects/{test-reachable-vrefs.js → reachable-vrefs.test.js} +2 -2
  103. package/test/virtual-objects/{test-rep-tostring.js → rep-tostring.test.js} +3 -5
  104. package/test/virtual-objects/{test-retain-remotable.js → retain-remotable.test.js} +25 -24
  105. package/test/virtual-objects/set-debug-label-instances.js +1 -1
  106. package/test/virtual-objects/state-shape.test.js +389 -0
  107. package/test/virtual-objects/{test-virtualObjectGC.js → virtualObjectGC.test.js} +39 -38
  108. package/test/virtual-objects/{test-virtualObjectManager.js → virtualObjectManager.test.js} +104 -8
  109. package/test/virtual-objects/{test-vo-real-gc.js → vo-real-gc.test.js} +8 -8
  110. package/test/virtual-objects/{test-weakcollections-vref-handling.js → weakcollections-vref-handling.test.js} +1 -2
  111. package/test/{test-vo-test-harness.js → vo-test-harness.test.js} +13 -10
  112. package/test/{test-vpid-liveslots.js → vpid-liveslots.test.js} +105 -5
  113. package/test/waitUntilQuiescent.d.ts +3 -0
  114. package/test/waitUntilQuiescent.d.ts.map +1 -0
  115. package/test/waitUntilQuiescent.js +2 -1
  116. package/test/weakset-dropped-remotable.test.js +50 -0
  117. package/tools/fakeCollectionManager.d.ts +14 -0
  118. package/tools/fakeCollectionManager.d.ts.map +1 -0
  119. package/tools/fakeCollectionManager.js +44 -0
  120. package/tools/fakeVirtualObjectManager.d.ts +32 -0
  121. package/tools/fakeVirtualObjectManager.d.ts.map +1 -0
  122. package/tools/fakeVirtualObjectManager.js +62 -0
  123. package/tools/fakeVirtualSupport.d.ts +278 -0
  124. package/tools/fakeVirtualSupport.d.ts.map +1 -0
  125. package/tools/fakeVirtualSupport.js +389 -0
  126. package/tools/prepare-strict-test-env.d.ts +37 -0
  127. package/tools/prepare-strict-test-env.d.ts.map +1 -0
  128. package/tools/prepare-strict-test-env.js +124 -0
  129. package/tools/prepare-test-env.d.ts +2 -0
  130. package/tools/prepare-test-env.d.ts.map +1 -0
  131. package/tools/prepare-test-env.js +13 -0
  132. package/tools/setup-vat-data.d.ts +9 -0
  133. package/tools/setup-vat-data.d.ts.map +1 -0
  134. package/tools/setup-vat-data.js +95 -0
  135. package/tools/vo-test-harness.d.ts +33 -0
  136. package/tools/vo-test-harness.d.ts.map +1 -0
  137. package/tools/vo-test-harness.js +164 -0
  138. package/CHANGELOG.md +0 -61
  139. package/test/kmarshal.js +0 -79
  140. package/test/test-handled-promises.js +0 -360
  141. 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 { Fail } from '@agoric/assert';
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.deepEqual(log.shift(), 'one');
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.deepEqual(log.shift(), 'two true');
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.deepEqual(log.shift(), 'two true');
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.deepEqual(log.shift(), 'sent p1p2p3');
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.5.|schemata',
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.5.skey',
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.5.skey',
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.deepEqual(log.shift(), false);
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.deepEqual(log.shift(), 'disavowed pres1');
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.deepEqual(log.shift(), 'tried duplicate disavow');
977
+ t.is(log.shift(), 'tried duplicate disavow');
979
978
  loggedError(/attempt to disavow unknown/);
980
- t.deepEqual(log.shift(), 'tried to disavow Promise');
979
+ t.is(log.shift(), 'tried to disavow Promise');
981
980
  loggedError(/attempt to disavow an export/);
982
- t.deepEqual(log.shift(), 'tried to disavow export');
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.deepEqual(log.shift(), 'tried to send to disavowed');
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,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import { waitUntilQuiescent } from './waitUntilQuiescent.js';
2
3
  import { makeDummyMeterControl } from './dummyMeterControl.js';
3
4
 
@@ -1,12 +1,13 @@
1
+ // @ts-nocheck
1
2
  import test from 'ava';
2
- import '@endo/init/debug.js';
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 #6", in vref o+2/6 (o+2 means
18
- // scalarMapStore, non-durable, and /6 means collectionID=6)
19
- const vref = 'o+v2/6';
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, 7); // last was 6
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('store lifecycle 1', async t => {
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('store lifecycle 2', async t => {
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('store lifecycle 3', async t => {
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('store lifecycle 4', async t => {
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('store lifecycle 5', async t => {
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('store lifecycle 6', async t => {
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('store lifecycle 7', async t => {
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('store lifecycle 8', async t => {
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,5 +1,4 @@
1
1
  import test from 'ava';
2
- import '@endo/init/debug.js';
3
2
 
4
3
  import { setupTestLiveslots } from '../liveslots-helpers.js';
5
4
  import { buildRootObject, mapRef } from '../gc-helpers.js';
@@ -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(vatParameters) {
63
- return harden(['startVat', vatParameters]);
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 '@agoric/assert';
5
- import { kser, kunser } from './kmarshal.js';
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', async t => {
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', async t => {
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: /^illegal cross-facet access/,
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: /^illegal cross-facet access/,
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', async t => {
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', async t => {
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', async t => {
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', async t => {
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', async t => {
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);