Skip to content

Commit

Permalink
test(async-flow): use prepareTestAsyncFlowTools(t,...)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 26, 2024
1 parent cf3fe86 commit adf2870
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
21 changes: 21 additions & 0 deletions packages/async-flow/test/_utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { prepareAsyncFlowTools } from '../src/async-flow.js';

/**
* @param {*} t
* @param {import('@agoric/base-zone').Zone} zone
* @param {Parameters<typeof prepareAsyncFlowTools>[1]} powers
* @returns

Check warning on line 7 in packages/async-flow/test/_utils.js

View workflow job for this annotation

GitHub Actions / lint-rest

Missing JSDoc @returns type
*/
export const prepareTestAsyncFlowTools = (t, zone, powers) => {
const { asyncFlow: rawAsyncFlow, ...rest } = prepareAsyncFlowTools(
zone,
powers,
);
/** @type {typeof rawAsyncFlow} */
const asyncFlow = (zone, name, guestFunc, opts) => {

Check failure on line 15 in packages/async-flow/test/_utils.js

View workflow job for this annotation

GitHub Actions / lint-rest

'zone' is already declared in the upper scope on line 9 column 46
const { panicHandler = e => t.log('Handled panic', e) } = opts || {};
return rawAsyncFlow(zone, name, guestFunc, { panicHandler, ...opts });
};
return harden({ asyncFlow, ...rest });
};
harden(prepareTestAsyncFlowTools);
10 changes: 4 additions & 6 deletions packages/async-flow/test/async-flow-crank.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { prepareVowTools } from '@agoric/vow';
import { makeDurableZone } from '@agoric/zone/durable.js';

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

/**
* @import {PromiseKit} from '@endo/promise-kit'
* @import {Zone} from '@agoric/base-zone'
* @import {Ephemera} from './types.js';
*/

const neverSettlesP = new Promise(() => {});
Expand All @@ -30,7 +28,7 @@ const neverSettlesP = new Promise(() => {});
*/
const testPlay1 = async (t, zone) => {
const vowTools = prepareVowTools(zone);
const { asyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});

Expand All @@ -48,7 +46,7 @@ const testPlay1 = async (t, zone) => {
*/
const testPlay2 = async (t, zone) => {
const vowTools = prepareVowTools(zone);
const { asyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});

Expand All @@ -63,7 +61,7 @@ const testPlay2 = async (t, zone) => {
*/
const testPlay3 = async (t, zone) => {
const vowTools = prepareVowTools(zone);
const { asyncFlow, allWokenP } = prepareAsyncFlowTools(zone, {
const { asyncFlow, allWokenP } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});

Expand Down
6 changes: 3 additions & 3 deletions packages/async-flow/test/async-flow-early-completion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isVow } from '@agoric/vow/src/vow-utils.js';
import { prepareVowTools } from '@agoric/vow';
import { makeDurableZone } from '@agoric/zone/durable.js';

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

/**
* @import {Zone} from '@agoric/base-zone';
Expand Down Expand Up @@ -59,7 +59,7 @@ const firstLogLen = 7;
const testFirstPlay = async (t, zone) => {
t.log('firstPlay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
const makeOrchestra = prepareOrchestra(zone);
Expand Down Expand Up @@ -141,7 +141,7 @@ const testFirstPlay = async (t, zone) => {
const testBadShortReplay = async (t, zone, rejection) => {
t.log('badShortReplay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
prepareOrchestra(zone);
Expand Down
6 changes: 2 additions & 4 deletions packages/async-flow/test/async-flow-no-this.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import { makeHeapZone } from '@agoric/zone/heap.js';
import { makeVirtualZone } from '@agoric/zone/virtual.js';
import { makeDurableZone } from '@agoric/zone/durable.js';

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

/**
* @import {Zone} from '@agoric/base-zone';
* @import {Vow, VowTools} from '@agoric/vow'
* @import {AsyncFlow} from '../src/async-flow.js'
*/

const { apply } = Reflect;
Expand All @@ -23,7 +21,7 @@ const { apply } = Reflect;
*/
const testPlay = async (t, zone) => {
const vowTools = prepareVowTools(zone);
const { asyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});

Expand Down
10 changes: 5 additions & 5 deletions packages/async-flow/test/async-flow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { makeHeapZone } from '@agoric/zone/heap.js';
import { makeVirtualZone } from '@agoric/zone/virtual.js';
import { makeDurableZone } from '@agoric/zone/durable.js';

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

/**
* @import {AsyncFlow} from '../src/async-flow.js'
Expand Down Expand Up @@ -62,7 +62,7 @@ const firstLogLen = 7;
const testFirstPlay = async (t, zone) => {
t.log('firstPlay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
const makeOrchestra = prepareOrchestra(zone);
Expand Down Expand Up @@ -139,7 +139,7 @@ const testFirstPlay = async (t, zone) => {
const testBadReplay = async (t, zone) => {
t.log('badReplay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
prepareOrchestra(zone);
Expand Down Expand Up @@ -206,7 +206,7 @@ const testBadReplay = async (t, zone) => {
const testGoodReplay = async (t, zone) => {
t.log('goodReplay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
prepareOrchestra(zone, 2); // Note change in new behavior
Expand Down Expand Up @@ -310,7 +310,7 @@ const testGoodReplay = async (t, zone) => {
const testAfterPlay = async (t, zone) => {
t.log('testAfterPlay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
prepareOrchestra(zone);
Expand Down
6 changes: 3 additions & 3 deletions packages/async-flow/test/bad-host.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { makeHeapZone } from '@agoric/zone/heap.js';
import { makeVirtualZone } from '@agoric/zone/virtual.js';
import { makeDurableZone } from '@agoric/zone/durable.js';

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

/**
* @import {PromiseKit} from '@endo/promise-kit'
Expand Down Expand Up @@ -51,7 +51,7 @@ const prepareBadHost = zone =>
const testBadHostFirstPlay = async (t, zone) => {
t.log('badHost firstPlay started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
const makeBadHost = prepareBadHost(zone);
Expand Down Expand Up @@ -112,7 +112,7 @@ const testBadHostFirstPlay = async (t, zone) => {
const testBadHostReplay1 = async (t, zone) => {
t.log('badHost replay1 started');
const vowTools = prepareVowTools(zone);
const { asyncFlow, adminAsyncFlow } = prepareAsyncFlowTools(zone, {
const { asyncFlow, adminAsyncFlow } = prepareTestAsyncFlowTools(t, zone, {
vowTools,
});
prepareBadHost(zone);
Expand Down

0 comments on commit adf2870

Please sign in to comment.