@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.
- package/README.md +1 -4
- package/package.json +13 -11
- package/src/action-types.d.ts +47 -20
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +19 -19
- package/src/ava-force-exit.d.mts +2 -0
- package/src/ava-force-exit.d.mts.map +1 -0
- package/src/ava-force-exit.mjs +6 -0
- package/src/batched-deliver.d.ts +6 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +7 -3
- package/src/build-cache-types.d.ts +33 -0
- package/src/build-cache-types.d.ts.map +1 -0
- package/src/build-cache-types.js +42 -0
- package/src/build-cache.d.ts +12 -0
- package/src/build-cache.d.ts.map +1 -0
- package/src/build-cache.js +184 -0
- package/src/callback.d.ts +9 -11
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +16 -10
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +0 -2
- package/src/chain-utils.d.ts +3 -1
- package/src/chain-utils.d.ts.map +1 -1
- package/src/chain-utils.js +6 -1
- package/src/config.d.ts +22 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +25 -3
- package/src/debug.d.ts +4 -1
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +26 -15
- package/src/index.d.ts +2 -1
- package/src/index.js +10 -3
- package/src/js-utils.d.ts +7 -3
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +24 -3
- package/src/keyMirror.d.ts +3 -0
- package/src/keyMirror.d.ts.map +1 -0
- package/src/keyMirror.js +45 -0
- package/src/kv-store.d.ts +33 -0
- package/src/kv-store.d.ts.map +1 -0
- package/src/kv-store.js +257 -0
- package/src/lib-chainStorage.d.ts +23 -12
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +18 -18
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +18 -3
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -1
- package/src/lib-nodejs/ava-unhandled-rejection.js +211 -20
- package/src/lib-nodejs/engine-gc.js +2 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +0 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +8 -7
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +3 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -1
- package/src/lib-nodejs/waitUntilQuiescent.js +5 -1
- package/src/lib-nodejs/worker-protocol.d.ts +1 -1
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
- package/src/lib-nodejs/worker-protocol.js +5 -5
- package/src/magic-cookie-test-only.d.ts.map +1 -1
- package/src/magic-cookie-test-only.js +0 -2
- package/src/marshal/board-client-utils.d.ts +19 -0
- package/src/marshal/board-client-utils.d.ts.map +1 -0
- package/src/{marshal.js → marshal/board-client-utils.js} +27 -52
- package/src/marshal/cap-data.d.ts +11 -0
- package/src/marshal/cap-data.d.ts.map +1 -0
- package/src/marshal/cap-data.js +19 -0
- package/src/marshal/inaccessible-val.d.ts +2 -0
- package/src/marshal/inaccessible-val.d.ts.map +1 -0
- package/src/marshal/inaccessible-val.js +15 -0
- package/src/marshal/pure-data.d.ts +8 -0
- package/src/marshal/pure-data.d.ts.map +1 -0
- package/src/marshal/pure-data.js +14 -0
- package/src/marshal/wrap-marshaller.d.ts +60 -0
- package/src/marshal/wrap-marshaller.d.ts.map +1 -0
- package/src/marshal/wrap-marshaller.js +432 -0
- package/src/module-utils.d.ts +1 -0
- package/src/module-utils.d.ts.map +1 -1
- package/src/module-utils.js +16 -0
- package/src/natural-sort.d.ts.map +1 -1
- package/src/natural-sort.js +48 -13
- package/src/netstring.d.ts +1 -1
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +5 -5
- package/src/node/buffer-line-transform.d.ts +10 -5
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +8 -4
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +3 -5
- package/src/node/fs-stream.d.ts +4 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +58 -9
- package/src/node/read-json.d.ts +2 -0
- package/src/node/read-json.d.ts.map +1 -0
- package/src/node/read-json.js +18 -0
- package/src/node/shutdown.js +1 -1
- package/src/priority-senders.d.ts +2 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +6 -4
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +0 -2
- package/src/ses-utils.d.ts +27 -5
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +115 -20
- package/src/storage-test-utils.d.ts +15 -5
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +62 -8
- package/src/tagged.d.ts +18 -1
- package/src/testing-utils.d.ts +4 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +88 -2
- package/src/typeGuards.d.ts +6 -2
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +7 -4
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +34 -19
- package/src/types.d.ts.map +1 -1
- package/src/types.js +173 -0
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +4 -3
- package/src/work-pool.d.ts +13 -0
- package/src/work-pool.d.ts.map +1 -0
- package/src/work-pool.js +233 -0
- package/vendor/anylogger.d.ts +98 -0
- package/vendor/anylogger.d.ts.map +1 -0
- package/vendor/anylogger.js +60 -0
- package/vendor/anylogger.ts +160 -0
- package/vendor/tsconfig.anylogger.json +15 -0
- package/exported.js +0 -2
- package/src/marshal.d.ts +0 -33
- package/src/marshal.d.ts.map +0 -1
- package/src/types.ts +0 -129
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/
|
|
1
|
+
export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
|
|
2
2
|
/**
|
|
3
3
|
* A basic marshaller whose unserializer produces Remotables. It can only
|
|
4
4
|
* serialize plain data, not Remotables.
|
|
@@ -14,7 +14,16 @@ export namespace defaultSerializer {
|
|
|
14
14
|
let stringify: (obj: any) => string;
|
|
15
15
|
}
|
|
16
16
|
export const slotStringUnserialize: (capData: any) => any;
|
|
17
|
-
export function
|
|
17
|
+
export function makeAsyncQueue<T>(): {
|
|
18
|
+
enqueue: (data: T) => void;
|
|
19
|
+
iterable: {
|
|
20
|
+
[Symbol.asyncIterator](): AsyncGenerator<Awaited<T> | undefined, void, unknown>;
|
|
21
|
+
};
|
|
22
|
+
cancel: () => boolean;
|
|
23
|
+
};
|
|
24
|
+
export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2], { eachMessage }?: {
|
|
25
|
+
eachMessage?: (m: StorageMessage) => void;
|
|
26
|
+
}): {
|
|
18
27
|
rootNode: import("@endo/exo").Guarded<{
|
|
19
28
|
getPath(): string;
|
|
20
29
|
getStoreKey(): Promise<VStorageKey>;
|
|
@@ -30,13 +39,13 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
30
39
|
toStorage: ((message: StorageMessage) => string | number | true | any[] | {
|
|
31
40
|
storeName: string;
|
|
32
41
|
storeSubkey: string;
|
|
33
|
-
} | null) & import("@endo/
|
|
42
|
+
} | null) & import("@endo/marshal").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | {
|
|
34
43
|
storeName: string;
|
|
35
44
|
storeSubkey: string;
|
|
36
45
|
} | null>;
|
|
37
46
|
};
|
|
38
47
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
39
|
-
export function documentStorageSchema(t:
|
|
48
|
+
export function documentStorageSchema(t: ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
|
|
40
49
|
note: string;
|
|
41
50
|
} | {
|
|
42
51
|
node: string;
|
|
@@ -60,7 +69,8 @@ export type MockChainStorageRootMethods = {
|
|
|
60
69
|
};
|
|
61
70
|
export type MockChainStorageRoot = StorageNode & MockChainStorageRootMethods;
|
|
62
71
|
import { makeChainStorageRoot } from './lib-chainStorage.js';
|
|
63
|
-
import type { StorageNode } from './lib-chainStorage.js';
|
|
64
72
|
import type { StorageMessage } from './lib-chainStorage.js';
|
|
73
|
+
import type { StorageNode } from './lib-chainStorage.js';
|
|
74
|
+
import type { ExecutionContext } from 'ava';
|
|
65
75
|
import type { Marshaller } from './lib-chainStorage.js';
|
|
66
76
|
//# sourceMappingURL=storage-test-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AA0BO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;;eAMU,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;mBAEzB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;;AA8CjC,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAa1D,+BAFM,CAAC;oBASA,CAAC;;;;;EA6Bd;AAWM,6CAJI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,oBAC1C;IAAE,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;CAAE;;;;;oBAwD3B,CAAC;;;;UA4FT,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;sBAd3B,MAAM,KACJ,MAAM,EAAE;;0BA/FP,cAAc;;;2IAAd,cAAc;;;;EAkH7B;AAoBM,4CADO,oBAAoB,CA2BjC;AAUM,yCAPI,iBAAiB,OAAO,CAAC,WACzB,oBAAoB,GAAG,cAAc,QACrC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,CAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,GAAG;IAChD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,iBAkDL;6BAtGa,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;aAIrC,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,CAAC,EAAE,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCAxTJ,uBAAuB;oCAOU,uBAAuB;iCAAvB,uBAAuB;sCACxE,KAAK;gCAD4C,uBAAuB"}
|
|
@@ -5,13 +5,14 @@ import { makeMarshal, Remotable } from '@endo/marshal';
|
|
|
5
5
|
import { makeTracer } from './debug.js';
|
|
6
6
|
import { NonNullish } from './errors.js';
|
|
7
7
|
import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js';
|
|
8
|
-
import { unmarshalFromVstorage } from './marshal.js';
|
|
8
|
+
import { unmarshalFromVstorage } from './marshal/board-client-utils.js';
|
|
9
9
|
import { bindAllMethods } from './method-tools.js';
|
|
10
10
|
import { eventLoopIteration } from './testing-utils.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @import {TotalMap} from './types.js';
|
|
14
14
|
* @import {Marshaller, StorageEntry, StorageMessage, StorageNode, StreamCell} from './lib-chainStorage.js';
|
|
15
|
+
* @import {ExecutionContext} from 'ava';
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
const trace = makeTracer('StorTU', false);
|
|
@@ -88,6 +89,55 @@ const makeSlotStringUnserialize = () => {
|
|
|
88
89
|
};
|
|
89
90
|
export const slotStringUnserialize = makeSlotStringUnserialize();
|
|
90
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @example to iterate over storage messages
|
|
94
|
+
*
|
|
95
|
+
* ```js
|
|
96
|
+
* const q = makeAsyncQueue<StorageMessage>();
|
|
97
|
+
* const storage = makeFakeStorageKit('published', undefined, { eachMessage: q.enqueue });
|
|
98
|
+
* for (const message of q.iterable) { ... }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @template T
|
|
102
|
+
*/
|
|
103
|
+
export const makeAsyncQueue = () => {
|
|
104
|
+
/** @type {T[]} */
|
|
105
|
+
const queue = [];
|
|
106
|
+
/** @type {null | ((r: undefined) => void)} */
|
|
107
|
+
let resolve = null;
|
|
108
|
+
let done = false;
|
|
109
|
+
|
|
110
|
+
/** @param {T} data */
|
|
111
|
+
const enqueue = data => {
|
|
112
|
+
queue.push(data);
|
|
113
|
+
if (resolve) {
|
|
114
|
+
resolve(undefined);
|
|
115
|
+
resolve = null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
let alreadyIterating = false;
|
|
120
|
+
const iterable = {
|
|
121
|
+
async *[Symbol.asyncIterator]() {
|
|
122
|
+
assert(!alreadyIterating, `AsyncQueue is already iterating`);
|
|
123
|
+
alreadyIterating = true;
|
|
124
|
+
await null;
|
|
125
|
+
while (!done) {
|
|
126
|
+
if (queue.length === 0) {
|
|
127
|
+
await new Promise(r => (resolve = r));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
while (queue.length > 0) {
|
|
131
|
+
yield queue.shift();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const cancel = () => (done = true);
|
|
138
|
+
return harden({ enqueue, iterable, cancel });
|
|
139
|
+
};
|
|
140
|
+
|
|
91
141
|
/**
|
|
92
142
|
* For testing, creates a chainStorage root node over an in-memory map and
|
|
93
143
|
* exposes both the map and the sequence of received messages. The `sequence`
|
|
@@ -95,8 +145,13 @@ export const slotStringUnserialize = makeSlotStringUnserialize();
|
|
|
95
145
|
*
|
|
96
146
|
* @param {string} rootPath
|
|
97
147
|
* @param {Parameters<typeof makeChainStorageRoot>[2]} [rootOptions]
|
|
148
|
+
* @param {{ eachMessage?: (m: StorageMessage) => void }} [spyOpts]
|
|
98
149
|
*/
|
|
99
|
-
export const makeFakeStorageKit = (
|
|
150
|
+
export const makeFakeStorageKit = (
|
|
151
|
+
rootPath,
|
|
152
|
+
rootOptions,
|
|
153
|
+
{ eachMessage } = {},
|
|
154
|
+
) => {
|
|
100
155
|
const resolvedOptions = { sequence: true, ...rootOptions };
|
|
101
156
|
/** @type {TotalMap<string, string>} */
|
|
102
157
|
const data = new Map();
|
|
@@ -133,6 +188,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
133
188
|
/** @param {StorageMessage} message */
|
|
134
189
|
message => {
|
|
135
190
|
messages.push(message);
|
|
191
|
+
eachMessage?.(message);
|
|
136
192
|
switch (message.method) {
|
|
137
193
|
case 'getStoreKey': {
|
|
138
194
|
const [key] = message.args;
|
|
@@ -183,7 +239,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
183
239
|
try {
|
|
184
240
|
streamCell = JSON.parse(oldVal);
|
|
185
241
|
assert(isStreamCell(streamCell));
|
|
186
|
-
} catch
|
|
242
|
+
} catch {
|
|
187
243
|
streamCell = undefined;
|
|
188
244
|
}
|
|
189
245
|
// StreamCells reset at block boundaries.
|
|
@@ -236,7 +292,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
236
292
|
|
|
237
293
|
return {
|
|
238
294
|
rootNode,
|
|
239
|
-
|
|
295
|
+
|
|
240
296
|
data: /** @type {Map<string, string>} */ (data),
|
|
241
297
|
updateNewCellBlockHeight,
|
|
242
298
|
getValues,
|
|
@@ -281,9 +337,7 @@ export const makeMockChainStorageRoot = () => {
|
|
|
281
337
|
getBody: (path, marshaller = defaultMarshaller, index = -1) => {
|
|
282
338
|
data.size || Fail`no data in storage`;
|
|
283
339
|
/**
|
|
284
|
-
* @type {ReturnType<
|
|
285
|
-
* typeof import('@endo/marshal').makeMarshal
|
|
286
|
-
* >['fromCapData']}
|
|
340
|
+
* @type {ReturnType<typeof makeMarshal>['fromCapData']}
|
|
287
341
|
*/
|
|
288
342
|
const fromCapData = (...args) =>
|
|
289
343
|
Reflect.apply(marshaller.fromCapData, marshaller, args);
|
|
@@ -294,7 +348,7 @@ export const makeMockChainStorageRoot = () => {
|
|
|
294
348
|
};
|
|
295
349
|
|
|
296
350
|
/**
|
|
297
|
-
* @param {
|
|
351
|
+
* @param {ExecutionContext<unknown>} t
|
|
298
352
|
* @param {MockChainStorageRoot | FakeStorageKit} storage
|
|
299
353
|
* @param {({ note: string } | { node: string; owner: string }) &
|
|
300
354
|
* ({ pattern: string; replacement: string } | {}) & {
|
package/src/tagged.d.ts
CHANGED
|
@@ -3,7 +3,24 @@
|
|
|
3
3
|
// different name to avoid confusion with pass-style "tagged"
|
|
4
4
|
export { Tagged as TypeTag };
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* CAVEAT: We use a constant string here to avoid exposing a `unique symbol`
|
|
8
|
+
* type publicly, such as with:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* declare const mySymbol: unique symbol;
|
|
12
|
+
*
|
|
13
|
+
* Without this workaround, we've observed errors when using at least
|
|
14
|
+
* `typescript@5.9.3`'s `tsc` to generate declaration files (.d.ts) for
|
|
15
|
+
* consumers of modules that in turn import the declaration:
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* error TS9006: Declaration emit for this file requires using private name
|
|
19
|
+
* 'tag' from module '.../internal/src/tagged"'. An explicit
|
|
20
|
+
* type annotation may unblock declaration emit.
|
|
21
|
+
*/
|
|
22
|
+
// declare const tag: unique symbol;
|
|
23
|
+
declare const tag: 'Symbol(tag)';
|
|
7
24
|
|
|
8
25
|
export type TagContainer<Token> = {
|
|
9
26
|
readonly [tag]: Token;
|
package/src/testing-utils.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export function eventLoopIteration(): Promise<any>;
|
|
2
2
|
export function inspectMapStore(store: MapStore): object;
|
|
3
|
+
export function testInterruptedSteps<Input = any, Context = unknown>(t: AvaT<Context>, allSteps: readonly TestStep<Input>[], doInterrupt?: (t: AvaT<Context>) => ERef<void>): Promise<void>;
|
|
4
|
+
export type TestStep<Input = any> = readonly [stepName: string, fn: (input: Partial<Input>, label: string) => Partial<Input> | PromiseLike<Partial<Input>>];
|
|
3
5
|
import type { MapStore } from '@agoric/store';
|
|
6
|
+
import type { ExecutionContext as AvaT } from 'ava';
|
|
7
|
+
import type { ERef } from '@endo/eventual-send';
|
|
4
8
|
//# sourceMappingURL=testing-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAmBO,mDACwC;AAgBxC,uCAHI,QAAQ,GACN,MAAM,CAsBlB;AAqBM,qCANO,KAAK,QACL,OAAO,eACV,KAAK,OAAO,CAAC,YACb,SAAS,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAC1B,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,iBA8D1C;qBA7Ea,KAAK,UACN,SAAS,CACjB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC3F;8BAzDuB,eAAe;8CACC,KAAK;0BACzB,qBAAqB"}
|
package/src/testing-utils.js
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* https://github.com/Agoric/agoric-sdk/issues/7503
|
|
5
5
|
*/
|
|
6
6
|
/* global setImmediate */
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @import {MapStore} from '@agoric/store';
|
|
9
|
+
* @import {ExecutionContext as AvaT} from 'ava';
|
|
10
|
+
* @import {ERef} from '@endo/eventual-send';
|
|
11
|
+
*/
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* A workaround for some issues with fake time in tests.
|
|
@@ -35,7 +39,8 @@ export const inspectMapStore = store => {
|
|
|
35
39
|
const obj = {};
|
|
36
40
|
for (const key of store.keys()) {
|
|
37
41
|
const value = store.get(key);
|
|
38
|
-
const hasKeys =
|
|
42
|
+
const hasKeys =
|
|
43
|
+
typeof value === 'object' && value != null && 'keys' in value;
|
|
39
44
|
const index = stringOrTag(key);
|
|
40
45
|
if (hasKeys && 'get' in value) {
|
|
41
46
|
obj[index] = inspectMapStore(value);
|
|
@@ -51,3 +56,84 @@ export const inspectMapStore = store => {
|
|
|
51
56
|
return obj;
|
|
52
57
|
};
|
|
53
58
|
harden(inspectMapStore);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @template [Input=any]
|
|
62
|
+
* @typedef {readonly [
|
|
63
|
+
* stepName: string,
|
|
64
|
+
* fn: (input: Partial<Input>, label: string) => Partial<Input> | PromiseLike<Partial<Input>>,
|
|
65
|
+
* ]} TestStep
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* For each step, run to just before that point and pause for continuation after
|
|
70
|
+
* interrupt.
|
|
71
|
+
*
|
|
72
|
+
* @template [Input=any]
|
|
73
|
+
* @template [Context=unknown]
|
|
74
|
+
* @param {AvaT<Context>} t
|
|
75
|
+
* @param {readonly TestStep<Input>[]} allSteps
|
|
76
|
+
* @param {(t: AvaT<Context>) => ERef<void>} [doInterrupt]
|
|
77
|
+
*/
|
|
78
|
+
export const testInterruptedSteps = async (t, allSteps, doInterrupt) => {
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {{
|
|
81
|
+
* label: string;
|
|
82
|
+
* accum: Partial<Input>;
|
|
83
|
+
* }} RunState
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {string} label
|
|
88
|
+
* @param {readonly TestStep<Input>[]} steps
|
|
89
|
+
* @param {RunState} [runState]
|
|
90
|
+
* @returns {Promise<RunState>}
|
|
91
|
+
*/
|
|
92
|
+
const runSteps = async (label, steps, runState = { label, accum: {} }) => {
|
|
93
|
+
await null;
|
|
94
|
+
let accum = runState.accum;
|
|
95
|
+
const runLabel = runState.label;
|
|
96
|
+
for (const [stepName, fn] of steps) {
|
|
97
|
+
await t.notThrowsAsync(async () => {
|
|
98
|
+
accum = await fn(accum, runLabel);
|
|
99
|
+
}, `${label} ${stepName} must complete successfully`);
|
|
100
|
+
}
|
|
101
|
+
return { label: runLabel, accum };
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Sanity check
|
|
105
|
+
await runSteps('pre-interrupt', allSteps);
|
|
106
|
+
if (!doInterrupt) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @type {{
|
|
112
|
+
* runState: RunState;
|
|
113
|
+
* remainingSteps: readonly TestStep<Input>[];
|
|
114
|
+
* }[]}
|
|
115
|
+
*/
|
|
116
|
+
const pausedRuns = [];
|
|
117
|
+
for (let i = 0; i < allSteps.length; i += 1) {
|
|
118
|
+
const [beforeStepName] = allSteps[i];
|
|
119
|
+
const runState = await runSteps(
|
|
120
|
+
`pre-${beforeStepName}`,
|
|
121
|
+
allSteps.slice(0, i),
|
|
122
|
+
{ label: `pause-before-${beforeStepName}`, accum: {} },
|
|
123
|
+
);
|
|
124
|
+
pausedRuns.push({ runState, remainingSteps: allSteps.slice(i) });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Run the user code that interrupts the steps.
|
|
128
|
+
await doInterrupt(t);
|
|
129
|
+
|
|
130
|
+
// Verify a complete run post-interrupt.
|
|
131
|
+
await runSteps('post-interrupt', allSteps);
|
|
132
|
+
|
|
133
|
+
// Verify completion of each paused step.
|
|
134
|
+
for (const { runState, remainingSteps } of pausedRuns) {
|
|
135
|
+
const [beforeStepName] = remainingSteps[0];
|
|
136
|
+
await runSteps(`resumed-${beforeStepName}`, remainingSteps, runState);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
harden(testInterruptedSteps);
|
package/src/typeGuards.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {TypedPattern} from './types.js';
|
|
3
|
+
*/
|
|
1
4
|
export const StorageNodeShape: import("@endo/patterns").Matcher;
|
|
2
5
|
/** To be used only for 'helper' facets where the calls are from trusted code. */
|
|
3
6
|
export const UnguardedHelperI: import("@endo/patterns").InterfaceGuard<any>;
|
|
@@ -7,13 +10,14 @@ export const UnguardedHelperI: import("@endo/patterns").InterfaceGuard<any>;
|
|
|
7
10
|
* either a JS number or a stringified JS bigint.
|
|
8
11
|
*/
|
|
9
12
|
/**
|
|
10
|
-
* @type {
|
|
13
|
+
* @type {TypedPattern<BridgeBigInt>}
|
|
11
14
|
*/
|
|
12
|
-
export const BridgeBigIntShape:
|
|
15
|
+
export const BridgeBigIntShape: TypedPattern<BridgeBigInt>;
|
|
13
16
|
/**
|
|
14
17
|
* Ensure that callees passed a
|
|
15
18
|
* bridge message that was serialised from a Golang int64 or uint64 accept
|
|
16
19
|
* either a JS number or a stringified JS bigint.
|
|
17
20
|
*/
|
|
18
21
|
export type BridgeBigInt = number | `${bigint}`;
|
|
22
|
+
import type { TypedPattern } from './types.js';
|
|
19
23
|
//# sourceMappingURL=typeGuards.d.ts.map
|
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH,gEAA2D;AAE3D,iFAAiF;AACjF,4EAKE;AAEF;;;;GAIG;AAEH;;GAEG;AACH,gCAFU,aAAa,YAAY,CAAC,CAE0B;;;;;;2BARjD,MAAM,GAAG,GAAG,MAAM,EAAE;kCAdF,YAAY"}
|
package/src/typeGuards.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
// @jessie-check
|
|
2
1
|
// @ts-check
|
|
3
2
|
|
|
4
3
|
import { M } from '@endo/patterns';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import {TypedPattern} from './types.js';
|
|
7
|
+
*/
|
|
8
|
+
|
|
6
9
|
export const StorageNodeShape = M.remotable('StorageNode');
|
|
7
10
|
|
|
8
11
|
/** To be used only for 'helper' facets where the calls are from trusted code. */
|
|
9
12
|
export const UnguardedHelperI = M.interface(
|
|
10
13
|
'helper',
|
|
11
14
|
{},
|
|
12
|
-
// not exposed so
|
|
13
|
-
{
|
|
15
|
+
// not exposed so using `defaultGuards` is fine.
|
|
16
|
+
{ defaultGuards: 'passable' },
|
|
14
17
|
);
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -20,6 +23,6 @@ export const UnguardedHelperI = M.interface(
|
|
|
20
23
|
*/
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
|
-
* @type {
|
|
26
|
+
* @type {TypedPattern<BridgeBigInt>}
|
|
24
27
|
*/
|
|
25
28
|
export const BridgeBigIntShape = M.or(M.number(), M.string());
|
package/src/types-index.d.ts
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import type { ERef, RemotableBrand } from '@endo/eventual-send';
|
|
2
|
-
import type { Primitive } from '@endo/pass-style';
|
|
2
|
+
import type { Primitive, RemotableObject } from '@endo/pass-style';
|
|
3
3
|
import type { Pattern } from '@endo/patterns';
|
|
4
4
|
import type { Callable } from './ses-utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* A mapping of a tuple type (as from `Parameters<...>`) into a corresponding
|
|
7
|
+
* object type with named fields.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* RecordFromTuple<[string, bigint], ['denom', 'amount']>
|
|
12
|
+
* //=> { denom: string, amount: bigint }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type RecordFromTuple<Types extends readonly unknown[], Names extends Record<Exclude<keyof Types, keyof unknown[]>, string>> = {
|
|
16
|
+
[K in Exclude<keyof Types, keyof any[]> as Names[K]]: Types[K];
|
|
17
|
+
};
|
|
5
18
|
/**
|
|
6
19
|
* A map corresponding with a total function such that `get(key)` is assumed to
|
|
7
20
|
* always succeed.
|
|
@@ -35,21 +48,22 @@ export declare class SyncCallback<I extends (...args: unknown[]) => any> extends
|
|
|
35
48
|
isSync: true;
|
|
36
49
|
}
|
|
37
50
|
/**
|
|
38
|
-
Returns a boolean for whether the given type is primitive value or
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
* Returns a boolean for whether the given type is a primitive value or
|
|
52
|
+
* primitive type.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```
|
|
56
|
+
* IsPrimitive<'string'>
|
|
57
|
+
* //=> true
|
|
58
|
+
*
|
|
59
|
+
* IsPrimitive<string>
|
|
60
|
+
* //=> true
|
|
61
|
+
*
|
|
62
|
+
* IsPrimitive<Object>
|
|
63
|
+
* //=> false
|
|
51
64
|
*/
|
|
52
65
|
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
66
|
+
export type IsRemotable<T> = T extends RemotableObject ? true : T extends RemotableBrand<any, any> ? true : false;
|
|
53
67
|
/** Recursively extract the non-callable properties of T */
|
|
54
68
|
export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : {
|
|
55
69
|
[P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>;
|
|
@@ -61,10 +75,11 @@ export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ?
|
|
|
61
75
|
*/
|
|
62
76
|
export type Remote<Primary, Local = DataOnly<Primary>> = Primary | RemotableBrand<Local, Primary>;
|
|
63
77
|
/**
|
|
64
|
-
*
|
|
78
|
+
* A type that accepts either resolved or promised references that may be either
|
|
79
|
+
* near or marshalled. @see {ERef} and @see {Remote}.
|
|
65
80
|
*/
|
|
66
|
-
export type
|
|
67
|
-
declare const validatedType:
|
|
81
|
+
export type ERemote<Primary, Local = DataOnly<Primary>> = ERef<Remote<Primary, Local>>;
|
|
82
|
+
declare const validatedType: 'Symbol(validatedType)';
|
|
68
83
|
/**
|
|
69
84
|
* Tag a pattern with the static type it represents.
|
|
70
85
|
*/
|
|
@@ -78,8 +93,8 @@ export declare type PatternType<TM extends TypedPattern<any>> = TM extends Typed
|
|
|
78
93
|
*
|
|
79
94
|
* Note: remotables can only be matched as "remotable", not the specific kind.
|
|
80
95
|
*
|
|
81
|
-
* @see {
|
|
96
|
+
* @see {endoMustMatch} for the implementation. This one has a type annotation to narrow if the pattern is a TypedPattern.
|
|
82
97
|
*/
|
|
83
98
|
export declare type MustMatch = <P extends Pattern>(specimen: unknown, pattern: P, label?: string | number) => asserts specimen is P extends TypedPattern<any> ? PatternType<P> : unknown;
|
|
84
|
-
export {};
|
|
99
|
+
export type { TraceLogger } from './debug.js';
|
|
85
100
|
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceR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