@agoric/internal 0.3.3-dev-8430b4d.0.8430b4d → 0.3.3-dev-d5eddaf.0.d5eddaf
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/package.json +4 -4
- package/src/testing-utils.d.ts +2 -2
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-d5eddaf.0.d5eddaf",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "yarn run -T tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-d5eddaf.0.d5eddaf",
|
|
24
24
|
"@endo/cache-map": "^1.1.0",
|
|
25
25
|
"@endo/common": "^1.2.13",
|
|
26
26
|
"@endo/compartment-mapper": "^1.6.3",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"jessie.js": "^0.3.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
42
|
+
"@agoric/cosmic-proto": "0.4.1-dev-d5eddaf.0.d5eddaf",
|
|
43
43
|
"@endo/exo": "^1.5.12",
|
|
44
44
|
"@endo/init": "^1.1.12",
|
|
45
45
|
"@endo/ses-ava": "^1.3.2",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"typeCoverage": {
|
|
68
68
|
"atLeast": 92.89
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "d5eddafd1d0d753e222640ce22eb00da23acca03"
|
|
71
71
|
}
|
package/src/testing-utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function eventLoopIteration(): Promise<any>;
|
|
2
2
|
export function inspectMapStore(store: MapStore): object;
|
|
3
|
-
export function testInterruptedSteps<Context = unknown>(t: AvaT<Context>, allSteps: readonly TestStep[], doInterrupt
|
|
4
|
-
export type TestStep = readonly [stepName: string, fn: (input:
|
|
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>>];
|
|
5
5
|
import type { MapStore } from '@agoric/store';
|
|
6
6
|
import type { ExecutionContext as AvaT } from 'ava';
|
|
7
7
|
import type { ERef } from '@endo/eventual-send';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAmBO,mDACwC;AAgBxC,uCAHI,QAAQ,GACN,MAAM,CAsBlB;
|
|
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
|
@@ -58,9 +58,10 @@ export const inspectMapStore = store => {
|
|
|
58
58
|
harden(inspectMapStore);
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
+
* @template [Input=any]
|
|
61
62
|
* @typedef {readonly [
|
|
62
63
|
* stepName: string,
|
|
63
|
-
* fn: (input:
|
|
64
|
+
* fn: (input: Partial<Input>, label: string) => Partial<Input> | PromiseLike<Partial<Input>>,
|
|
64
65
|
* ]} TestStep
|
|
65
66
|
*/
|
|
66
67
|
|
|
@@ -68,26 +69,27 @@ harden(inspectMapStore);
|
|
|
68
69
|
* For each step, run to just before that point and pause for continuation after
|
|
69
70
|
* interrupt.
|
|
70
71
|
*
|
|
72
|
+
* @template [Input=any]
|
|
71
73
|
* @template [Context=unknown]
|
|
72
74
|
* @param {AvaT<Context>} t
|
|
73
|
-
* @param {readonly TestStep[]} allSteps
|
|
74
|
-
* @param {(t: AvaT<Context>) => ERef<void>} doInterrupt
|
|
75
|
+
* @param {readonly TestStep<Input>[]} allSteps
|
|
76
|
+
* @param {(t: AvaT<Context>) => ERef<void>} [doInterrupt]
|
|
75
77
|
*/
|
|
76
78
|
export const testInterruptedSteps = async (t, allSteps, doInterrupt) => {
|
|
77
79
|
/**
|
|
78
80
|
* @typedef {{
|
|
79
81
|
* label: string;
|
|
80
|
-
* accum
|
|
82
|
+
* accum: Partial<Input>;
|
|
81
83
|
* }} RunState
|
|
82
84
|
*/
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
87
|
* @param {string} label
|
|
86
|
-
* @param {readonly TestStep[]} steps
|
|
88
|
+
* @param {readonly TestStep<Input>[]} steps
|
|
87
89
|
* @param {RunState} [runState]
|
|
88
90
|
* @returns {Promise<RunState>}
|
|
89
91
|
*/
|
|
90
|
-
const runSteps = async (label, steps, runState = { label }) => {
|
|
92
|
+
const runSteps = async (label, steps, runState = { label, accum: {} }) => {
|
|
91
93
|
await null;
|
|
92
94
|
let accum = runState.accum;
|
|
93
95
|
const runLabel = runState.label;
|
|
@@ -101,11 +103,14 @@ export const testInterruptedSteps = async (t, allSteps, doInterrupt) => {
|
|
|
101
103
|
|
|
102
104
|
// Sanity check
|
|
103
105
|
await runSteps('pre-interrupt', allSteps);
|
|
106
|
+
if (!doInterrupt) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
111
|
* @type {{
|
|
107
112
|
* runState: RunState;
|
|
108
|
-
* remainingSteps: readonly TestStep[];
|
|
113
|
+
* remainingSteps: readonly TestStep<Input>[];
|
|
109
114
|
* }[]}
|
|
110
115
|
*/
|
|
111
116
|
const pausedRuns = [];
|
|
@@ -114,7 +119,7 @@ export const testInterruptedSteps = async (t, allSteps, doInterrupt) => {
|
|
|
114
119
|
const runState = await runSteps(
|
|
115
120
|
`pre-${beforeStepName}`,
|
|
116
121
|
allSteps.slice(0, i),
|
|
117
|
-
{ label: `pause-before-${beforeStepName}
|
|
122
|
+
{ label: `pause-before-${beforeStepName}`, accum: {} },
|
|
118
123
|
);
|
|
119
124
|
pausedRuns.push({ runState, remainingSteps: allSteps.slice(i) });
|
|
120
125
|
}
|