Skip to content

Commit

Permalink
fixup! review suggestions waking
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed May 19, 2024
1 parent ad8367c commit 377cdd9
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions packages/async-flow/test/async-flow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { makeDurableZone } from '@agoric/zone/durable.js';

import { prepareAsyncFlowTools } from '../src/async-flow.js';

/**
* @import {AsyncFlow} from '../src/async-flow.js'
*/

/**
* @param {Zone} zone
* @param {number} [k]
Expand Down Expand Up @@ -100,7 +104,9 @@ const testFirstPlay = async (t, zone) => {
t.true(isVow(outcomeV));
r1.resolve('x');

const flow = adminAsyncFlow.getFlowForOutcomeVow(outcomeV);
const flow = zone.makeOnce('flow', () =>
adminAsyncFlow.getFlowForOutcomeVow(outcomeV),
);
t.is(passStyleOf(flow), 'remotable');

await promiseStep;
Expand Down Expand Up @@ -144,9 +150,9 @@ const testBadReplay = async (t, zone) => {
const { guestMethod } = {
async guestMethod(gOrch7, g1, _p3) {
t.log(' badReplay about to await g1');
resolveStep(true);
await g1;
gOrch7.vow();
resolveStep(true);
// This is a replay error
gOrch7.scale(4);
t.fail('badReplay must not reach here');
Expand All @@ -162,17 +168,19 @@ const testBadReplay = async (t, zone) => {
const outcomeV = /** @type {Vow} */ (
zone.makeOnce('outcomeV', () => Fail`need outcomeV`)
);
const flow = /** @type {AsyncFlow} */ (
zone.makeOnce('flow', () => Fail`need flow`)
);
const flow1 = adminAsyncFlow.getFlowForOutcomeVow(outcomeV);
t.is(flow, flow1);
t.is(passStyleOf(flow), 'remotable');

// This unblocks `await p2;` but only after the replay failure is fixed in
// the next incarnation.
hOrch7.resolve('y');
// TODO I shouldn't need to do this.
await adminAsyncFlow.wakeAll();
await promiseStep;
t.is(await when(hOrch7.vow()), 'y');

const flow = adminAsyncFlow.getFlowForOutcomeVow(outcomeV);
t.is(passStyleOf(flow), 'remotable');

const logDump = flow.dump();
t.is(logDump.length, firstLogLen);

Expand All @@ -185,7 +193,7 @@ const testBadReplay = async (t, zone) => {
);

t.log(' badReplay failures', flow.getOptFatalProblem());
t.log('badReplay done', await promiseStep);
t.log('badReplay done');
};

/**
Expand Down Expand Up @@ -245,14 +253,17 @@ const testGoodReplay = async (t, zone) => {
const outcomeV = /** @type {Vow} */ (
zone.makeOnce('outcomeV', () => Fail`need outcomeV`)
);
const flow = /** @type {AsyncFlow} */ (
zone.makeOnce('flow', () => Fail`need flow`)
);
const flow1 = adminAsyncFlow.getFlowForOutcomeVow(outcomeV);
t.is(flow, flow1);
t.is(passStyleOf(flow), 'remotable');

const v2 = hOrch7.vow();
t.is(await when(v2), 'y');
await eventLoopIteration();

const flow = adminAsyncFlow.getFlowForOutcomeVow(outcomeV);
t.is(passStyleOf(flow), 'remotable');

await promiseStep;

const { vow: v1 } = zone.makeOnce('v1', () => Fail`need v1`);
Expand Down Expand Up @@ -316,12 +327,20 @@ const testAfterPlay = async (t, zone) => {
const outcomeV = /** @type {Vow} */ (
zone.makeOnce('outcomeV', () => Fail`need outcomeV`)
);
const flow = /** @type {AsyncFlow} */ (
zone.makeOnce('flow', () => Fail`need flow`)
);
t.is(passStyleOf(flow), 'remotable');

t.throws(() => adminAsyncFlow.getFlowForOutcomeVow(outcomeV), {
message:
'key "[Alleged: VowInternalsKit vowV0]" not found in collection "flowForOutcomeVow"',
});

// Even this doesn't wake it up.
flow.wake();
await eventLoopIteration();

t.log('testAfterDoneReplay done');
};

Expand Down

0 comments on commit 377cdd9

Please sign in to comment.