@agoric/internal 0.4.0 → 0.4.1-upgrade-23-dev-bd79330.0.bd79330

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 (131) hide show
  1. package/README.md +1 -4
  2. package/package.json +13 -11
  3. package/src/action-types.d.ts +47 -20
  4. package/src/action-types.d.ts.map +1 -1
  5. package/src/action-types.js +19 -19
  6. package/src/ava-force-exit.d.mts +2 -0
  7. package/src/ava-force-exit.d.mts.map +1 -0
  8. package/src/ava-force-exit.mjs +6 -0
  9. package/src/batched-deliver.d.ts +6 -2
  10. package/src/batched-deliver.d.ts.map +1 -1
  11. package/src/batched-deliver.js +7 -3
  12. package/src/build-cache-types.d.ts +33 -0
  13. package/src/build-cache-types.d.ts.map +1 -0
  14. package/src/build-cache-types.js +42 -0
  15. package/src/build-cache.d.ts +12 -0
  16. package/src/build-cache.d.ts.map +1 -0
  17. package/src/build-cache.js +184 -0
  18. package/src/callback.d.ts +9 -11
  19. package/src/callback.d.ts.map +1 -1
  20. package/src/callback.js +16 -10
  21. package/src/chain-storage-paths.d.ts.map +1 -1
  22. package/src/chain-storage-paths.js +0 -2
  23. package/src/chain-utils.d.ts +3 -1
  24. package/src/chain-utils.d.ts.map +1 -1
  25. package/src/chain-utils.js +6 -1
  26. package/src/config.d.ts +22 -3
  27. package/src/config.d.ts.map +1 -1
  28. package/src/config.js +25 -3
  29. package/src/debug.d.ts +4 -1
  30. package/src/debug.d.ts.map +1 -1
  31. package/src/debug.js +26 -15
  32. package/src/index.d.ts +2 -1
  33. package/src/index.js +10 -3
  34. package/src/js-utils.d.ts +7 -3
  35. package/src/js-utils.d.ts.map +1 -1
  36. package/src/js-utils.js +24 -3
  37. package/src/keyMirror.d.ts +3 -0
  38. package/src/keyMirror.d.ts.map +1 -0
  39. package/src/keyMirror.js +45 -0
  40. package/src/kv-store.d.ts +33 -0
  41. package/src/kv-store.d.ts.map +1 -0
  42. package/src/kv-store.js +257 -0
  43. package/src/lib-chainStorage.d.ts +23 -12
  44. package/src/lib-chainStorage.d.ts.map +1 -1
  45. package/src/lib-chainStorage.js +18 -18
  46. package/src/lib-nodejs/ava-unhandled-rejection.d.ts +18 -3
  47. package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -1
  48. package/src/lib-nodejs/ava-unhandled-rejection.js +211 -20
  49. package/src/lib-nodejs/engine-gc.js +2 -2
  50. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +0 -2
  51. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
  52. package/src/lib-nodejs/spawnSubprocessWorker.js +8 -7
  53. package/src/lib-nodejs/waitUntilQuiescent.d.ts +3 -0
  54. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -1
  55. package/src/lib-nodejs/waitUntilQuiescent.js +5 -1
  56. package/src/lib-nodejs/worker-protocol.d.ts +1 -1
  57. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
  58. package/src/lib-nodejs/worker-protocol.js +5 -5
  59. package/src/magic-cookie-test-only.d.ts.map +1 -1
  60. package/src/magic-cookie-test-only.js +0 -2
  61. package/src/marshal/board-client-utils.d.ts +19 -0
  62. package/src/marshal/board-client-utils.d.ts.map +1 -0
  63. package/src/{marshal.js → marshal/board-client-utils.js} +27 -52
  64. package/src/marshal/cap-data.d.ts +11 -0
  65. package/src/marshal/cap-data.d.ts.map +1 -0
  66. package/src/marshal/cap-data.js +19 -0
  67. package/src/marshal/inaccessible-val.d.ts +2 -0
  68. package/src/marshal/inaccessible-val.d.ts.map +1 -0
  69. package/src/marshal/inaccessible-val.js +15 -0
  70. package/src/marshal/pure-data.d.ts +8 -0
  71. package/src/marshal/pure-data.d.ts.map +1 -0
  72. package/src/marshal/pure-data.js +14 -0
  73. package/src/marshal/wrap-marshaller.d.ts +60 -0
  74. package/src/marshal/wrap-marshaller.d.ts.map +1 -0
  75. package/src/marshal/wrap-marshaller.js +432 -0
  76. package/src/module-utils.d.ts +1 -0
  77. package/src/module-utils.d.ts.map +1 -1
  78. package/src/module-utils.js +16 -0
  79. package/src/natural-sort.d.ts.map +1 -1
  80. package/src/natural-sort.js +48 -13
  81. package/src/netstring.d.ts +1 -1
  82. package/src/netstring.d.ts.map +1 -1
  83. package/src/netstring.js +5 -5
  84. package/src/node/buffer-line-transform.d.ts +10 -5
  85. package/src/node/buffer-line-transform.d.ts.map +1 -1
  86. package/src/node/buffer-line-transform.js +8 -4
  87. package/src/node/createBundles.d.ts.map +1 -1
  88. package/src/node/createBundles.js +3 -5
  89. package/src/node/fs-stream.d.ts +4 -1
  90. package/src/node/fs-stream.d.ts.map +1 -1
  91. package/src/node/fs-stream.js +58 -9
  92. package/src/node/read-json.d.ts +2 -0
  93. package/src/node/read-json.d.ts.map +1 -0
  94. package/src/node/read-json.js +18 -0
  95. package/src/node/shutdown.js +1 -1
  96. package/src/priority-senders.d.ts +2 -1
  97. package/src/priority-senders.d.ts.map +1 -1
  98. package/src/priority-senders.js +6 -4
  99. package/src/queue.d.ts.map +1 -1
  100. package/src/queue.js +0 -2
  101. package/src/ses-utils.d.ts +27 -5
  102. package/src/ses-utils.d.ts.map +1 -1
  103. package/src/ses-utils.js +115 -20
  104. package/src/storage-test-utils.d.ts +15 -5
  105. package/src/storage-test-utils.d.ts.map +1 -1
  106. package/src/storage-test-utils.js +62 -8
  107. package/src/tagged.d.ts +18 -1
  108. package/src/testing-utils.d.ts +4 -0
  109. package/src/testing-utils.d.ts.map +1 -1
  110. package/src/testing-utils.js +88 -2
  111. package/src/typeGuards.d.ts +6 -2
  112. package/src/typeGuards.d.ts.map +1 -1
  113. package/src/typeGuards.js +7 -4
  114. package/src/types-index.d.ts +1 -0
  115. package/src/types.d.ts +34 -19
  116. package/src/types.d.ts.map +1 -1
  117. package/src/types.js +173 -0
  118. package/src/upgrade-api.d.ts.map +1 -1
  119. package/src/upgrade-api.js +4 -3
  120. package/src/work-pool.d.ts +13 -0
  121. package/src/work-pool.d.ts.map +1 -0
  122. package/src/work-pool.js +233 -0
  123. package/vendor/anylogger.d.ts +98 -0
  124. package/vendor/anylogger.d.ts.map +1 -0
  125. package/vendor/anylogger.js +60 -0
  126. package/vendor/anylogger.ts +160 -0
  127. package/vendor/tsconfig.anylogger.json +15 -0
  128. package/exported.js +0 -2
  129. package/src/marshal.d.ts +0 -33
  130. package/src/marshal.d.ts.map +0 -1
  131. package/src/types.ts +0 -129
@@ -0,0 +1,257 @@
1
+ // @ts-check
2
+ import { Fail } from '@endo/errors';
3
+
4
+ /**
5
+ * @import {Database} from 'better-sqlite3';
6
+ */
7
+
8
+ /**
9
+ * @template [T=string]
10
+ * @typedef {{
11
+ * has: (key: string) => boolean;
12
+ * get: (key: string) => T | undefined;
13
+ * getNextKey: (previousKey: string) => string | undefined;
14
+ * set: (key: string, value: T) => void;
15
+ * delete: (key: string) => void;
16
+ * }} KVStore
17
+ */
18
+
19
+ /**
20
+ * @param {Database} db The SQLite database connection.
21
+ * @param {() => void} beforeMutation Called before mutating methods to
22
+ * establish a DB transaction if needed
23
+ * @param {(...args: string[]) => void} trace Called after set/delete to record
24
+ * a debug log
25
+ * @returns {KVStore}
26
+ */
27
+
28
+ export function makeKVStore(db, beforeMutation, trace) {
29
+ db.exec(`
30
+ CREATE TABLE IF NOT EXISTS kvStore (
31
+ key TEXT,
32
+ value TEXT,
33
+ PRIMARY KEY (key)
34
+ )
35
+ `);
36
+
37
+ const sqlKVGet = db.prepare(`
38
+ SELECT value
39
+ FROM kvStore
40
+ WHERE key = ?
41
+ `);
42
+ sqlKVGet.pluck(true);
43
+
44
+ /**
45
+ * Obtain the value stored for a given key.
46
+ *
47
+ * @param {string} key The key whose value is sought.
48
+ * @returns {string | undefined} the (string) value for the given key, or
49
+ * undefined if there is no such value.
50
+ * @throws if key is not a string.
51
+ */
52
+ function get(key) {
53
+ typeof key === 'string' || Fail`key must be a string`;
54
+ return /** @type {string | undefined} */ (sqlKVGet.get(key));
55
+ }
56
+
57
+ const sqlKVGetNextKey = db.prepare(`
58
+ SELECT key
59
+ FROM kvStore
60
+ WHERE key > ?
61
+ LIMIT 1
62
+ `);
63
+ sqlKVGetNextKey.pluck(true);
64
+
65
+ /**
66
+ * getNextKey enables callers to iterate over all keys within a given range.
67
+ * To build an iterator of all keys from start (inclusive) to end (exclusive),
68
+ * do:
69
+ *
70
+ * ```js
71
+ * function* iterate(start, end) {
72
+ * if (kvStore.has(start)) {
73
+ * yield start;
74
+ * }
75
+ * let prev = start;
76
+ * while (true) {
77
+ * let next = kvStore.getNextKey(prev);
78
+ * if (!next || next >= end) {
79
+ * break;
80
+ * }
81
+ * yield next;
82
+ * prev = next;
83
+ * }
84
+ * }
85
+ * ```
86
+ *
87
+ * @param {string} previousKey The key returned will always be later than this
88
+ * one.
89
+ * @returns {string | undefined} a key string, or undefined if we reach the
90
+ * end of the store
91
+ * @throws if previousKey is not a string
92
+ */
93
+
94
+ function getNextKey(previousKey) {
95
+ typeof previousKey === 'string' || Fail`previousKey must be a string`;
96
+ return /** @type {string | undefined} */ (sqlKVGetNextKey.get(previousKey));
97
+ }
98
+
99
+ /**
100
+ * Test if the state contains a value for a given key.
101
+ *
102
+ * @param {string} key The key that is of interest.
103
+ * @returns {boolean} true if a value is stored for the key, false if not.
104
+ * @throws if key is not a string.
105
+ */
106
+ function has(key) {
107
+ typeof key === 'string' || Fail`key must be a string`;
108
+ return get(key) !== undefined;
109
+ }
110
+
111
+ const sqlKVSet = db.prepare(`
112
+ INSERT INTO kvStore (key, value)
113
+ VALUES (?, ?)
114
+ ON CONFLICT DO UPDATE SET value = excluded.value
115
+ `);
116
+
117
+ /**
118
+ * Store a value for a given key. The value will replace any prior value if
119
+ * there was one.
120
+ *
121
+ * @param {string} key The key whose value is being set.
122
+ * @param {string} value The value to set the key to.
123
+ * @throws if either parameter is not a string.
124
+ */
125
+ function set(key, value) {
126
+ typeof key === 'string' || Fail`key must be a string`;
127
+ typeof value === 'string' || Fail`value must be a string`;
128
+ // synchronous read after write within a transaction is safe
129
+ // The transaction's overall success will be awaited during commit
130
+ beforeMutation();
131
+ sqlKVSet.run(key, value);
132
+ trace('set', key, value);
133
+ }
134
+
135
+ const sqlKVDel = db.prepare(`
136
+ DELETE FROM kvStore
137
+ WHERE key = ?
138
+ `);
139
+
140
+ /**
141
+ * Remove any stored value for a given key. It is permissible for there to be
142
+ * no existing stored value for the key.
143
+ *
144
+ * @param {string} key The key whose value is to be deleted
145
+ * @throws if key is not a string.
146
+ */
147
+ function del(key) {
148
+ typeof key === 'string' || Fail`key must be a string`;
149
+ beforeMutation();
150
+ sqlKVDel.run(key);
151
+ trace('del', key);
152
+ }
153
+
154
+ const kvStore = {
155
+ has,
156
+ get,
157
+ getNextKey,
158
+ set,
159
+ delete: del,
160
+ };
161
+
162
+ return kvStore;
163
+ }
164
+
165
+ // TODO: Replace compareByCodePoints and makeKVStoreFromMap and
166
+ // provideEnhancedKVStore with imports when
167
+ // available.
168
+ // https://github.com/Agoric/agoric-sdk/pull/10299
169
+
170
+ export const compareByCodePoints = (left, right) => {
171
+ const leftIter = left[Symbol.iterator]();
172
+ const rightIter = right[Symbol.iterator]();
173
+ for (;;) {
174
+ const { value: leftChar } = leftIter.next();
175
+ const { value: rightChar } = rightIter.next();
176
+ if (leftChar === undefined && rightChar === undefined) {
177
+ return 0;
178
+ } else if (leftChar === undefined) {
179
+ // left is a prefix of right.
180
+ return -1;
181
+ } else if (rightChar === undefined) {
182
+ // right is a prefix of left.
183
+ return 1;
184
+ }
185
+ const leftCodepoint = /** @type {number} */ (leftChar.codePointAt(0));
186
+ const rightCodepoint = /** @type {number} */ (rightChar.codePointAt(0));
187
+ if (leftCodepoint < rightCodepoint) return -1;
188
+ if (leftCodepoint > rightCodepoint) return 1;
189
+ }
190
+ };
191
+
192
+ /**
193
+ * @template [T=unknown]
194
+ * @param {Map<string, T>} map
195
+ * @returns {KVStore<T>}
196
+ */
197
+ export const makeKVStoreFromMap = map => {
198
+ let sortedKeys;
199
+ let priorKeyReturned;
200
+ let priorKeyIndex;
201
+
202
+ const ensureSorted = () => {
203
+ if (sortedKeys) return;
204
+ sortedKeys = [...map.keys()].sort(compareByCodePoints);
205
+ };
206
+
207
+ const clearGetNextKeyCache = () => {
208
+ priorKeyReturned = undefined;
209
+ priorKeyIndex = -1;
210
+ };
211
+ clearGetNextKeyCache();
212
+
213
+ const clearSorted = () => {
214
+ sortedKeys = undefined;
215
+ clearGetNextKeyCache();
216
+ };
217
+
218
+ /** @type {KVStore<T>} */
219
+ const fakeStore = harden({
220
+ has: key => map.has(key),
221
+ get: key => map.get(key),
222
+ getNextKey: priorKey => {
223
+ assert.typeof(priorKey, 'string');
224
+ ensureSorted();
225
+ const start =
226
+ priorKeyReturned === undefined
227
+ ? 0
228
+ : // If priorKeyReturned <= priorKey, start just after it.
229
+ (compareByCodePoints(priorKeyReturned, priorKey) <= 0 &&
230
+ priorKeyIndex + 1) ||
231
+ // Else if priorKeyReturned immediately follows priorKey, start at
232
+ // its index (and expect to return it again).
233
+ (sortedKeys.at(priorKeyIndex - 1) === priorKey && priorKeyIndex) ||
234
+ // Otherwise, start at the beginning.
235
+ 0;
236
+ for (let i = start; i < sortedKeys.length; i += 1) {
237
+ const key = sortedKeys[i];
238
+ if (compareByCodePoints(key, priorKey) <= 0) continue;
239
+ priorKeyReturned = key;
240
+ priorKeyIndex = i;
241
+ return key;
242
+ }
243
+ // reached end without finding the key, so clear our cache
244
+ clearGetNextKeyCache();
245
+ return undefined;
246
+ },
247
+ set: (key, value) => {
248
+ if (!map.has(key)) clearSorted();
249
+ map.set(key, value);
250
+ },
251
+ delete: key => {
252
+ if (map.has(key)) clearSorted();
253
+ map.delete(key);
254
+ },
255
+ });
256
+ return fakeStore;
257
+ };
@@ -26,17 +26,20 @@ export function makeChainStorageRoot(handleStorageMessage: (message: StorageMess
26
26
  * falling back to an inert object with the correct interface (but incomplete
27
27
  * behavior) when that is unavailable.
28
28
  *
29
- * @param {ERef<StorageNode?>} storageNodeRef
29
+ * @param {ERef<Remote<StorageNode> | null>} storageNodeRef
30
30
  * @param {string} childName
31
- * @returns {Promise<StorageNode>}
31
+ * @returns {Promise<Remote<StorageNode>>}
32
32
  */
33
- export function makeStorageNodeChild(storageNodeRef: ERef<StorageNode | null>, childName: string): Promise<StorageNode>;
33
+ export function makeStorageNodeChild(storageNodeRef: ERef<Remote<StorageNode> | null>, childName: string): Promise<Remote<StorageNode>>;
34
34
  /**
35
35
  * @import {ERef} from '@endo/far';
36
- * @import {PassableCap} from '@endo/marshal';
37
- * @import {TypedPattern} from './types.js';
36
+ * @import {Marshal, Passable} from '@endo/marshal';
37
+ * @import {Remote, ERemote, TypedPattern} from './types.js';
38
+ * @import {EMarshaller} from './marshal/wrap-marshaller.js';
39
+ * @import {Zone} from '@agoric/base-zone';
40
+ * @import {Callback} from './types.js';
38
41
  */
39
- /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */
42
+ /** @typedef {Marshal<unknown>} Marshaller */
40
43
  /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
41
44
  /**
42
45
  * Defined by vstorageStoreKey in vstorage.go
@@ -50,7 +53,8 @@ export function makeStorageNodeChild(storageNodeRef: ERef<StorageNode | null>, c
50
53
  /**
51
54
  * @template [T=unknown]
52
55
  * @typedef StreamCell
53
- * @property {string} blockHeight decimal representation of a natural number
56
+ * @property {string} blockHeight corresponding with the write of `values`
57
+ * (decimal representation of a natural number)
54
58
  * @property {T[]} values
55
59
  */
56
60
  /** @type {TypedPattern<StreamCell>} */
@@ -58,7 +62,7 @@ export const StreamCellShape: TypedPattern<StreamCell>;
58
62
  export function isStreamCell(cell: any): cell is StreamCell;
59
63
  /** @type {(name: string) => void} */
60
64
  export const assertPathSegment: (name: string) => void;
61
- export function prepareChainStorageNode(zone: import("@agoric/base-zone").Zone): (messenger: import("./types.js").Callback<(message: StorageMessage) => any>, path: string, args_2?: {
65
+ export function prepareChainStorageNode(zone: Zone): (messenger: Callback<(message: StorageMessage) => any>, path: string, args_2?: {
62
66
  sequence?: boolean | undefined;
63
67
  } | undefined) => import("@endo/exo").Guarded<{
64
68
  getPath(): string;
@@ -68,8 +72,8 @@ export function prepareChainStorageNode(zone: import("@agoric/base-zone").Zone):
68
72
  }): StorageNode;
69
73
  setValue(value: string): Promise<void>;
70
74
  }>;
71
- export function makeSerializeToStorage(storageNode: ERef<StorageNode>, marshaller: ERef<Marshaller>): (value: PassableCap) => Promise<void>;
72
- export type Marshaller = ReturnType<typeof import("@endo/marshal").makeMarshal>;
75
+ export function makeSerializeToStorage(storageNode: ERemote<StorageNode>, marshaller: ERemote<EMarshaller>): (value: Passable) => Promise<void>;
76
+ export type Marshaller = Marshal<unknown>;
73
77
  export type Unserializer = Pick<Marshaller, "fromCapData">;
74
78
  /**
75
79
  * Defined by vstorageStoreKey in vstorage.go
@@ -82,7 +86,8 @@ export type VStorageKey = {
82
86
  };
83
87
  export type StreamCell<T = unknown> = {
84
88
  /**
85
- * decimal representation of a natural number
89
+ * corresponding with the write of `values`
90
+ * (decimal representation of a natural number)
86
91
  */
87
92
  blockHeight: string;
88
93
  values: T[];
@@ -165,7 +170,13 @@ export type StorageMessage = {
165
170
  method: StorageUpdateEntriesMessageMethod;
166
171
  args: StorageUpdateEntriesMessageArgs;
167
172
  };
173
+ import type { Remote } from './types.js';
168
174
  import type { ERef } from '@endo/far';
169
175
  import type { TypedPattern } from './types.js';
170
- import type { PassableCap } from '@endo/marshal';
176
+ import type { Zone } from '@agoric/base-zone';
177
+ import type { Callback } from './types.js';
178
+ import type { ERemote } from './types.js';
179
+ import type { EMarshaller } from './marshal/wrap-marshaller.js';
180
+ import type { Passable } from '@endo/marshal';
181
+ import type { Marshal } from '@endo/marshal';
171
182
  //# sourceMappingURL=lib-chainStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAiPA;;;;;;;;;;;;GAYG;AACH,2DATW,CAAC,OAAO,EAAE,cAAc,KAA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;;;gDAGA,KAAK,GAAG,kBAAkB,GAAG,QAAQ;;;;mCAGrC,6BAA6B,GACnC,iCAAiC;;;;0CAG3B,CAAC,IAAI,EAAE,MAAM,CAAC;;;;2BAEd,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;;;;8CAErC,YAAY,EAAE;;;;6BAEd;IACJ,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC,GACD;IACE,MAAM,EAAE,iCAAiC,CAAC;IAC1C,IAAI,EAAE,+BAA+B,CAAC;CACvC;4BAtIwC,YAAY;0BAFrC,WAAW;kCAEc,YAAY;0BAErC,mBAAmB;8BACf,YAAY;6BAHS,YAAY;iCAC9B,8BAA8B;8BAFxB,eAAe;6BAAf,eAAe"}
@@ -8,11 +8,14 @@ import * as cb from './callback.js';
8
8
 
9
9
  /**
10
10
  * @import {ERef} from '@endo/far';
11
- * @import {PassableCap} from '@endo/marshal';
12
- * @import {TypedPattern} from './types.js';
11
+ * @import {Marshal, Passable} from '@endo/marshal';
12
+ * @import {Remote, ERemote, TypedPattern} from './types.js';
13
+ * @import {EMarshaller} from './marshal/wrap-marshaller.js';
14
+ * @import {Zone} from '@agoric/base-zone';
15
+ * @import {Callback} from './types.js';
13
16
  */
14
17
 
15
- /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */
18
+ /** @typedef {Marshal<unknown>} Marshaller */
16
19
  /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
17
20
 
18
21
  /**
@@ -28,7 +31,8 @@ import * as cb from './callback.js';
28
31
  /**
29
32
  * @template [T=unknown]
30
33
  * @typedef StreamCell
31
- * @property {string} blockHeight decimal representation of a natural number
34
+ * @property {string} blockHeight corresponding with the write of `values`
35
+ * (decimal representation of a natural number)
32
36
  * @property {T[]} values
33
37
  */
34
38
 
@@ -143,17 +147,15 @@ harden(assertPathSegment);
143
147
  */
144
148
 
145
149
  /**
146
- * @param {import('@agoric/base-zone').Zone} zone
150
+ * @param {Zone} zone
147
151
  */
148
152
  export const prepareChainStorageNode = zone => {
149
153
  /**
150
154
  * Create a storage node for a given backing storage interface and path.
151
155
  *
152
- * @param {import('./types.js').Callback<
153
- * (message: StorageMessage) => any
154
- * >} messenger
155
- * a callback for sending a storageMessage object to the storage
156
- * implementation (cf. golang/cosmos/x/vstorage/vstorage.go)
156
+ * @param {Callback<(message: StorageMessage) => any>} messenger a callback
157
+ * for sending a storageMessage object to the storage implementation (cf.
158
+ * golang/cosmos/x/vstorage/vstorage.go)
157
159
  * @param {string} path
158
160
  * @param {object} [options]
159
161
  * @param {boolean} [options.sequence] set values with `append` messages
@@ -166,9 +168,7 @@ export const prepareChainStorageNode = zone => {
166
168
  'ChainStorageNode',
167
169
  ChainStorageNodeI,
168
170
  /**
169
- * @param {import('./types.js').Callback<
170
- * (message: StorageMessage) => any
171
- * >} messenger
171
+ * @param {Callback<(message: StorageMessage) => any>} messenger
172
172
  * @param {string} path
173
173
  * @param {object} [options]
174
174
  * @param {boolean} [options.sequence]
@@ -281,9 +281,9 @@ const makeNullStorageNode = () => {
281
281
  * falling back to an inert object with the correct interface (but incomplete
282
282
  * behavior) when that is unavailable.
283
283
  *
284
- * @param {ERef<StorageNode?>} storageNodeRef
284
+ * @param {ERef<Remote<StorageNode> | null>} storageNodeRef
285
285
  * @param {string} childName
286
- * @returns {Promise<StorageNode>}
286
+ * @returns {Promise<Remote<StorageNode>>}
287
287
  */
288
288
  export async function makeStorageNodeChild(storageNodeRef, childName) {
289
289
  const existingStorageNode = await storageNodeRef;
@@ -294,9 +294,9 @@ harden(makeStorageNodeChild);
294
294
 
295
295
  // TODO find a better module for this
296
296
  /**
297
- * @param {ERef<StorageNode>} storageNode
298
- * @param {ERef<Marshaller>} marshaller
299
- * @returns {(value: PassableCap) => Promise<void>}
297
+ * @param {ERemote<StorageNode>} storageNode
298
+ * @param {ERemote<EMarshaller>} marshaller
299
+ * @returns {(value: Passable) => Promise<void>}
300
300
  */
301
301
  export const makeSerializeToStorage = (storageNode, marshaller) => {
302
302
  return async value => {
@@ -1,12 +1,27 @@
1
1
  /**
2
- * @import {ExecutionContext, Macro, TestFn} from 'ava';
2
+ * @import {ExecutionContext, ImplementationFn, Macro, MacroDeclarationOptions,TestFn} from 'ava';
3
3
  */
4
+ /** Not an official AVA feature, so prefix with `AGORIC_` */
5
+ export const AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
6
+ /** Backwards compatibility... */
4
7
  export const AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
5
- export const SUBTEST_PREFIX: "(unhandled rejection subprocess): ";
6
- export function makeExpectUnhandledRejection<C>({ test, importMetaUrl }: {
8
+ export function countUnhandled(work: () => any | Promise<any>, { gcAndFinalize }: {
9
+ gcAndFinalize: () => Promise<void>;
10
+ }): Promise<{
11
+ unhandled: number;
12
+ pending: number;
13
+ seenUnhandled: number;
14
+ }>;
15
+ export function makeExpectUnhandledRejection<C>({ test, sameWorker, importMetaUrl, }: {
7
16
  test: TestFn<C>;
17
+ sameWorker?: boolean | undefined;
8
18
  importMetaUrl: string;
9
19
  }): (expectedUnhandled: number) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>;
20
+ export function makeExpectUnhandledRejectionMacro<C = unknown>({ test, sameWorker, importMetaUrl, }: {
21
+ test: TestFn<C>;
22
+ sameWorker?: boolean | undefined;
23
+ importMetaUrl: string;
24
+ }): (numUnhandled: number, innerMacro?: Macro<A, C>) => Macro<A, C>;
10
25
  import type { TestFn } from 'ava';
11
26
  import type { ExecutionContext } from 'ava';
12
27
  import type { Macro } from 'ava';
@@ -1 +1 @@
1
- {"version":3,"file":"ava-unhandled-rejection.d.ts","sourceRoot":"","sources":["ava-unhandled-rejection.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH,8CACE,wCAAwC,CA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