@agoric/async-flow 0.1.1-upgrade-17-dev-ec448b0.0 → 0.1.1-upgrade-18-dev-d7c994b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -28
- package/docs/async-flow-states.key +0 -0
- package/docs/async-flow-states.md +2 -1
- package/docs/async-flow-states.png +0 -0
- package/index.d.ts +1 -2
- package/index.js +1 -2
- package/package.json +18 -19
- package/src/async-flow.d.ts.map +1 -1
- package/src/async-flow.js +47 -3
- package/src/endowments.d.ts +0 -1
- package/src/endowments.d.ts.map +1 -1
- package/src/endowments.js +7 -35
- package/src/equate.d.ts.map +1 -1
- package/src/equate.js +16 -8
- package/src/log-store.d.ts +39 -2
- package/src/log-store.d.ts.map +1 -1
- package/src/log-store.js +121 -22
- package/src/replay-membrane.d.ts +23 -4
- package/src/replay-membrane.d.ts.map +1 -1
- package/src/replay-membrane.js +61 -35
- package/src/type-guards.d.ts.map +1 -1
- package/src/type-guards.js +1 -0
- package/src/types-index.d.ts +2 -0
- package/src/types.d.ts +86 -166
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +213 -0
- package/test/_utils.js +22 -0
- package/test/async-flow-crank.test.js +4 -6
- package/test/async-flow-early-completion.test.js +28 -8
- package/test/async-flow-no-this.js +2 -4
- package/test/async-flow.test.js +13 -5
- package/test/bad-host.test.js +13 -3
- package/test/endowments.test.js +22 -2
- package/test/equate.test.js +5 -5
- package/test/exports.test.js +8 -0
- package/test/log-store.test.js +46 -11
- package/test/prepare-test-env-ava.js +2 -20
- package/test/replay-membrane-eventual.test.js +97 -41
- package/test/snapshots/exports.test.js.md +14 -0
- package/test/snapshots/exports.test.js.snap +0 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +0 -3
- /package/src/{types.js → types-index.js} +0 -0
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import '@agoric/swingset-
|
|
2
|
-
import { wrapTest } from '@endo/ses-ava';
|
|
3
|
-
import rawTest from 'ava';
|
|
1
|
+
import '@agoric/swingset-vat/tools/prepare-strict-test-env-ava.js';
|
|
4
2
|
|
|
5
3
|
import { environmentOptionsListHas } from '@endo/env-options';
|
|
6
|
-
import { reincarnate } from '@agoric/swingset-liveslots/tools/setup-vat-data.js';
|
|
7
4
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
/** @type {ReturnType<typeof reincarnate>} */
|
|
11
|
-
let incarnation;
|
|
12
|
-
|
|
13
|
-
export const annihilate = () => {
|
|
14
|
-
incarnation = reincarnate({ relaxDurabilityRules: false });
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const getBaggage = () => {
|
|
18
|
-
return incarnation.fakeVomKit.cm.provideBaggage();
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const nextLife = () => {
|
|
22
|
-
incarnation = reincarnate(incarnation);
|
|
23
|
-
};
|
|
5
|
+
export * from '@agoric/swingset-vat/tools/prepare-strict-test-env-ava.js';
|
|
24
6
|
|
|
25
7
|
export const asyncFlowVerbose = () => {
|
|
26
8
|
// TODO figure out how we really want to control this.
|
|
@@ -17,10 +17,9 @@ import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
|
17
17
|
|
|
18
18
|
import { prepareLogStore } from '../src/log-store.js';
|
|
19
19
|
import { prepareBijection } from '../src/bijection.js';
|
|
20
|
-
import {
|
|
20
|
+
import { makeReplayMembraneForTesting } from '../src/replay-membrane.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @import {PromiseKit} from '@endo/promise-kit'
|
|
24
23
|
* @import {Zone} from '@agoric/base-zone'
|
|
25
24
|
* @import {LogStore} from '../src/log-store.js';
|
|
26
25
|
* @import {Bijection} from '../src/bijection.js';
|
|
@@ -41,11 +40,19 @@ const preparePingee = zone =>
|
|
|
41
40
|
* @typedef {ReturnType<ReturnType<preparePingee>>} Pingee
|
|
42
41
|
*/
|
|
43
42
|
|
|
43
|
+
const testMode = /** @type {const} */ ({
|
|
44
|
+
normal: 'normal',
|
|
45
|
+
noEventualSend: 'noEventualSend',
|
|
46
|
+
retry: 'retry',
|
|
47
|
+
});
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* @param {any} t
|
|
46
51
|
* @param {Zone} zone
|
|
52
|
+
* @param {testMode[keyof testMode]} [mode]
|
|
47
53
|
*/
|
|
48
|
-
const testFirstPlay = async (t, zone) => {
|
|
54
|
+
const testFirstPlay = async (t, zone, mode = testMode.normal) => {
|
|
55
|
+
t.log('testFirstPlay', mode);
|
|
49
56
|
const vowTools = prepareVowTools(zone);
|
|
50
57
|
const { makeVowKit } = vowTools;
|
|
51
58
|
const makeLogStore = prepareLogStore(zone);
|
|
@@ -57,22 +64,33 @@ const testFirstPlay = async (t, zone) => {
|
|
|
57
64
|
const log = zone.makeOnce('log', () => makeLogStore());
|
|
58
65
|
const bijection = zone.makeOnce('bij', makeBijection);
|
|
59
66
|
|
|
60
|
-
const mem =
|
|
67
|
+
const mem = makeReplayMembraneForTesting({
|
|
61
68
|
log,
|
|
62
69
|
bijection,
|
|
63
70
|
vowTools,
|
|
64
71
|
watchWake,
|
|
65
72
|
panic,
|
|
73
|
+
__eventualSendForTesting: mode !== testMode.noEventualSend,
|
|
66
74
|
});
|
|
67
75
|
|
|
68
|
-
const p1 = mem.hostToGuest(v1);
|
|
69
|
-
t.deepEqual(log.dump(), []);
|
|
70
|
-
|
|
71
76
|
/** @type {Pingee} */
|
|
72
77
|
const pingee = zone.makeOnce('pingee', () => makePingee());
|
|
78
|
+
const beforeSend = [
|
|
79
|
+
['checkCall', pingee, 'ping', ['call'], 0],
|
|
80
|
+
['doReturn', 0, undefined],
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const initialDump = [];
|
|
84
|
+
if (mode === testMode.retry) {
|
|
85
|
+
initialDump.push(...beforeSend);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const p1 = mem.hostToGuest(v1);
|
|
89
|
+
t.deepEqual(log.dump(), initialDump);
|
|
90
|
+
|
|
73
91
|
/** @type {Pingee} */
|
|
74
92
|
const guestPingee = mem.hostToGuest(pingee);
|
|
75
|
-
t.deepEqual(log.dump(),
|
|
93
|
+
t.deepEqual(log.dump(), initialDump);
|
|
76
94
|
|
|
77
95
|
const p = E(guestPingee).ping('send');
|
|
78
96
|
const pOnly = E.sendOnly(guestPingee).ping('sendOnly');
|
|
@@ -80,17 +98,29 @@ const testFirstPlay = async (t, zone) => {
|
|
|
80
98
|
|
|
81
99
|
guestPingee.ping('call');
|
|
82
100
|
|
|
101
|
+
/** @type {any[][]} */
|
|
102
|
+
const afterPingDump = [...beforeSend];
|
|
103
|
+
if (mode === testMode.noEventualSend) {
|
|
104
|
+
await t.throwsAsync(p, {
|
|
105
|
+
message:
|
|
106
|
+
/panic over "\[Error: guest eventual applyMethod not yet supported:/,
|
|
107
|
+
});
|
|
108
|
+
const dump = log.dump();
|
|
109
|
+
t.deepEqual(dump, afterPingDump);
|
|
110
|
+
return p;
|
|
111
|
+
}
|
|
112
|
+
|
|
83
113
|
t.is(await p, undefined);
|
|
84
114
|
const dump = log.dump();
|
|
85
115
|
const v3 = dump[3][2];
|
|
86
|
-
|
|
87
|
-
['checkCall', pingee, 'ping', ['call'], 0],
|
|
88
|
-
['doReturn', 0, undefined],
|
|
116
|
+
const afterSend = [
|
|
89
117
|
['checkSend', pingee, 'ping', ['send'], 2],
|
|
90
118
|
['doReturn', 2, v3],
|
|
91
119
|
['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
|
|
92
120
|
['doFulfill', v3, undefined],
|
|
93
|
-
]
|
|
121
|
+
];
|
|
122
|
+
afterPingDump.push(...afterSend);
|
|
123
|
+
t.deepEqual(dump, afterPingDump);
|
|
94
124
|
|
|
95
125
|
r1.resolve('x');
|
|
96
126
|
t.is(await p1, 'x');
|
|
@@ -109,8 +139,10 @@ const testFirstPlay = async (t, zone) => {
|
|
|
109
139
|
/**
|
|
110
140
|
* @param {any} t
|
|
111
141
|
* @param {Zone} zone
|
|
142
|
+
* @param {testMode[keyof testMode]} [mode]
|
|
112
143
|
*/
|
|
113
|
-
const testReplay = async (t, zone) => {
|
|
144
|
+
const testReplay = async (t, zone, mode = testMode.normal) => {
|
|
145
|
+
t.log('testReplay', mode);
|
|
114
146
|
const vowTools = prepareVowTools(zone);
|
|
115
147
|
prepareLogStore(zone);
|
|
116
148
|
prepareBijection(zone);
|
|
@@ -129,7 +161,7 @@ const testReplay = async (t, zone) => {
|
|
|
129
161
|
|
|
130
162
|
const dump = log.dump();
|
|
131
163
|
const v3 = dump[3][2];
|
|
132
|
-
|
|
164
|
+
const beforeY = [
|
|
133
165
|
['checkCall', pingee, 'ping', ['call'], 0],
|
|
134
166
|
['doReturn', 0, undefined],
|
|
135
167
|
['checkSend', pingee, 'ping', ['send'], 2],
|
|
@@ -137,14 +169,18 @@ const testReplay = async (t, zone) => {
|
|
|
137
169
|
['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
|
|
138
170
|
['doFulfill', v3, undefined],
|
|
139
171
|
['doFulfill', v1, 'x'],
|
|
140
|
-
]
|
|
172
|
+
];
|
|
173
|
+
const afterY = [['doFulfill', v2, 'y']];
|
|
174
|
+
const initialDump = beforeY;
|
|
175
|
+
t.deepEqual(dump, initialDump);
|
|
141
176
|
|
|
142
|
-
const mem =
|
|
177
|
+
const mem = makeReplayMembraneForTesting({
|
|
143
178
|
log,
|
|
144
179
|
bijection,
|
|
145
180
|
vowTools,
|
|
146
181
|
watchWake,
|
|
147
182
|
panic,
|
|
183
|
+
__eventualSendForTesting: mode !== testMode.noEventualSend,
|
|
148
184
|
});
|
|
149
185
|
t.true(log.isReplaying());
|
|
150
186
|
t.is(log.getIndex(), 0);
|
|
@@ -153,23 +189,15 @@ const testReplay = async (t, zone) => {
|
|
|
153
189
|
const p2 = mem.hostToGuest(v2);
|
|
154
190
|
// @ts-expect-error TS doesn't know that r2 is a resolver
|
|
155
191
|
r2.resolve('y');
|
|
156
|
-
await eventLoopIteration();
|
|
157
192
|
|
|
158
193
|
const p1 = mem.hostToGuest(v1);
|
|
159
194
|
mem.wake();
|
|
160
195
|
t.true(log.isReplaying());
|
|
161
196
|
t.is(log.getIndex(), 0);
|
|
162
|
-
t.deepEqual(log.dump(),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
['checkSend', pingee, 'ping', ['send'], 2],
|
|
166
|
-
['doReturn', 2, v3],
|
|
167
|
-
['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
|
|
168
|
-
['doFulfill', v3, undefined],
|
|
169
|
-
['doFulfill', v1, 'x'],
|
|
170
|
-
]);
|
|
197
|
+
t.deepEqual(log.dump(), initialDump);
|
|
198
|
+
|
|
199
|
+
const pingSend = E(guestPingee).ping('send');
|
|
171
200
|
|
|
172
|
-
E(guestPingee).ping('send');
|
|
173
201
|
// TODO Once https://github.com/endojs/endo/issues/2336 is fixed,
|
|
174
202
|
// the following `void` should not be needed. But strangely, TS isn't
|
|
175
203
|
// telling me a `void` is needed above, which is also incorrect.
|
|
@@ -177,20 +205,19 @@ const testReplay = async (t, zone) => {
|
|
|
177
205
|
|
|
178
206
|
guestPingee.ping('call');
|
|
179
207
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
[
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
]);
|
|
208
|
+
let finalDump;
|
|
209
|
+
if (mode === testMode.noEventualSend) {
|
|
210
|
+
t.true(log.isReplaying());
|
|
211
|
+
finalDump = beforeY;
|
|
212
|
+
} else {
|
|
213
|
+
t.is(await p1, 'x');
|
|
214
|
+
t.is(await p2, 'y');
|
|
215
|
+
t.false(log.isReplaying());
|
|
216
|
+
finalDump = [...beforeY, ...afterY];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
t.deepEqual(log.dump(), finalDump);
|
|
220
|
+
return pingSend;
|
|
194
221
|
};
|
|
195
222
|
|
|
196
223
|
test.serial('test heap replay-membrane settlement', async t => {
|
|
@@ -215,3 +242,32 @@ test.serial('test durable replay-membrane settlement', async t => {
|
|
|
215
242
|
const zone3 = makeDurableZone(getBaggage(), 'durableRoot');
|
|
216
243
|
return testReplay(t, zone3);
|
|
217
244
|
});
|
|
245
|
+
|
|
246
|
+
test.serial('test durable toggle eventual send', async t => {
|
|
247
|
+
annihilate();
|
|
248
|
+
|
|
249
|
+
nextLife();
|
|
250
|
+
const zone1 = makeDurableZone(getBaggage(), 'durableRoot');
|
|
251
|
+
await t.throwsAsync(() => testFirstPlay(t, zone1, testMode.noEventualSend), {
|
|
252
|
+
message:
|
|
253
|
+
/^panic over "\[Error: guest eventual applyMethod not yet supported:/,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
await eventLoopIteration();
|
|
257
|
+
nextLife();
|
|
258
|
+
const zone1a = makeDurableZone(getBaggage(), 'durableRoot');
|
|
259
|
+
await testFirstPlay(t, zone1a, testMode.retry);
|
|
260
|
+
|
|
261
|
+
await eventLoopIteration();
|
|
262
|
+
nextLife();
|
|
263
|
+
const zone2 = makeDurableZone(getBaggage(), 'durableRoot');
|
|
264
|
+
await t.throwsAsync(() => testReplay(t, zone2, testMode.noEventualSend), {
|
|
265
|
+
message:
|
|
266
|
+
/^panic over "\[Error: guest eventual applyMethod not yet supported:/,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
await eventLoopIteration();
|
|
270
|
+
nextLife();
|
|
271
|
+
const zone2a = makeDurableZone(getBaggage(), 'durableRoot');
|
|
272
|
+
await testReplay(t, zone2a, testMode.retry);
|
|
273
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./index.js","./src/async-flow.js","./src/bijection.js","./src/convert.js","./src/endowments.js","./src/ephemera.js","./src/equate.js","./src/log-store.js","./src/replay-membrane.js","./src/type-guards.js","./src/types-index.d.ts","./src/types.ts"],"version":"5.6.3"}
|
package/tsconfig.json
CHANGED
|
File without changes
|