Skip to content

Commit

Permalink
test(vow): update tests to use basic tools
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 21, 2024
1 parent ea2d6a7 commit 63f0294
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/vow/test/asVow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import test from 'ava';
import { E } from '@endo/far';
import { makeHeapZone } from '@agoric/base-zone/heap.js';

import { prepareVowTools } from '../src/tools.js';
import { prepareBasicVowTools } from '../src/tools.js';
import { getVowPayload, isVow } from '../src/vow-utils.js';

test('asVow takes a function that throws/returns synchronously and returns a vow', async t => {
const { watch, when, asVow } = prepareVowTools(makeHeapZone());
const { watch, when, asVow } = prepareBasicVowTools(makeHeapZone());

const fnThatThrows = () => {
throw Error('fail');
Expand Down Expand Up @@ -36,7 +36,7 @@ test('asVow takes a function that throws/returns synchronously and returns a vow
});

test('asVow does not resolve a vow to a vow', async t => {
const { watch, when, asVow } = prepareVowTools(makeHeapZone());
const { watch, when, asVow } = prepareBasicVowTools(makeHeapZone());

const testVow = watch(Promise.resolve('payload'));
const testVowAsVow = asVow(() => testVow);
Expand Down
4 changes: 2 additions & 2 deletions packages/vow/test/disconnect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import test from 'ava';

import { makeHeapZone } from '@agoric/base-zone/heap.js';
import { makeTagged } from '@endo/pass-style';
import { prepareVowTools } from '../src/tools.js';
import { prepareBasicVowTools } from '../src/tools.js';

/** @import {Vow} from '../src/types.js' */

test('retry on disconnection', async t => {
const zone = makeHeapZone();
const isRetryableReason = e => e && e.message === 'disconnected';

const { watch, when } = prepareVowTools(zone, {
const { watch, when } = prepareBasicVowTools(zone, {
isRetryableReason,
});
const makeTestVowV0 = zone.exoClass(
Expand Down
30 changes: 15 additions & 15 deletions packages/vow/test/watch-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import test from 'ava';
import { makeHeapZone } from '@agoric/base-zone/heap.js';
import { E, getInterfaceOf } from '@endo/far';

import { prepareVowTools } from '../src/tools.js';
import { prepareBasicVowTools } from '../src/tools.js';

test('allVows waits for a single vow to complete', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseP = Promise.resolve('promise');
const vowA = watch(testPromiseP);
Expand All @@ -20,7 +20,7 @@ test('allVows waits for a single vow to complete', async t => {

test('allVows waits for an array of vows to complete', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseAP = Promise.resolve('promiseA');
const testPromiseBP = Promise.resolve('promiseB');
Expand All @@ -36,7 +36,7 @@ test('allVows waits for an array of vows to complete', async t => {

test('allVows returns vows in order', async t => {
const zone = makeHeapZone();
const { watch, when, allVows, makeVowKit } = prepareVowTools(zone);
const { watch, when, allVows, makeVowKit } = prepareBasicVowTools(zone);
const kit = makeVowKit();

const testPromiseAP = Promise.resolve('promiseA');
Expand All @@ -55,7 +55,7 @@ test('allVows returns vows in order', async t => {

test('allVows rejects upon first rejection', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseAP = Promise.resolve('promiseA');
const testPromiseBP = Promise.reject(Error('rejectedA'));
Expand All @@ -75,7 +75,7 @@ test('allVows rejects upon first rejection', async t => {

test('allVows can accept vows awaiting other vows', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseAP = Promise.resolve('promiseA');
const testPromiseBP = Promise.resolve('promiseB');
Expand All @@ -93,7 +93,7 @@ test('allVows can accept vows awaiting other vows', async t => {

test('allVows - works with just promises', async t => {
const zone = makeHeapZone();
const { when, allVows } = prepareVowTools(zone);
const { when, allVows } = prepareBasicVowTools(zone);

const result = await when(
allVows([Promise.resolve('promiseA'), Promise.resolve('promiseB')]),
Expand All @@ -104,7 +104,7 @@ test('allVows - works with just promises', async t => {

test('allVows - watch promises mixed with vows', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseP = Promise.resolve('vow');
const vowA = watch(testPromiseP);
Expand All @@ -116,7 +116,7 @@ test('allVows - watch promises mixed with vows', async t => {

test('allVows can accept passable data (PureData)', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

const testPromiseP = Promise.resolve('vow');
const vowA = watch(testPromiseP);
Expand All @@ -135,7 +135,7 @@ const prepareAccount = zone =>

test('allVows supports Promise pipelining', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

// makeAccount returns a Promise
const prepareLocalChain = makeAccount => {
Expand Down Expand Up @@ -170,7 +170,7 @@ test('allVows supports Promise pipelining', async t => {

test('allVows does NOT support Vow pipelining', async t => {
const zone = makeHeapZone();
const { watch, when, allVows } = prepareVowTools(zone);
const { watch, when, allVows } = prepareBasicVowTools(zone);

// makeAccount returns a Vow
const prepareLocalChainVowish = makeAccount => {
Expand Down Expand Up @@ -202,7 +202,7 @@ test('allVows does NOT support Vow pipelining', async t => {

test('asPromise converts a vow to a promise', async t => {
const zone = makeHeapZone();
const { watch, asPromise } = prepareVowTools(zone);
const { watch, asPromise } = prepareBasicVowTools(zone);

const testPromiseP = Promise.resolve('test value');
const vow = watch(testPromiseP);
Expand All @@ -213,7 +213,7 @@ test('asPromise converts a vow to a promise', async t => {

test('asPromise handles vow rejection', async t => {
const zone = makeHeapZone();
const { watch, asPromise } = prepareVowTools(zone);
const { watch, asPromise } = prepareBasicVowTools(zone);

const testPromiseP = Promise.reject(new Error('test error'));
const vow = watch(testPromiseP);
Expand All @@ -223,7 +223,7 @@ test('asPromise handles vow rejection', async t => {

test('asPromise accepts and resolves promises', async t => {
const zone = makeHeapZone();
const { asPromise } = prepareVowTools(zone);
const { asPromise } = prepareBasicVowTools(zone);

const p = Promise.resolve('a promise');
const result = await asPromise(p);
Expand All @@ -232,7 +232,7 @@ test('asPromise accepts and resolves promises', async t => {

test('asPromise handles watcher arguments', async t => {
const zone = makeHeapZone();
const { watch, asPromise } = prepareVowTools(zone);
const { watch, asPromise } = prepareBasicVowTools(zone);

const testPromiseP = Promise.resolve('watcher test');
const vow = watch(testPromiseP);
Expand Down
10 changes: 5 additions & 5 deletions packages/vow/test/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import test from 'ava';

import { makeHeapZone } from '@agoric/base-zone/heap.js';

import { prepareVowTools } from '../src/tools.js';
import { prepareBasicVowTools } from '../src/tools.js';

/**
* @import {ExecutionContext} from 'ava'
Expand Down Expand Up @@ -59,7 +59,7 @@ const prepareArityCheckWatcher = (zone, t) => {
*/
test('ack watcher - shim', async t => {
const zone = makeHeapZone();
const { watch, when, makeVowKit } = prepareVowTools(zone);
const { watch, when, makeVowKit } = prepareBasicVowTools(zone);
const makeAckWatcher = prepareAckWatcher(zone, t);

const packet = harden({ portId: 'port-1', channelId: 'channel-1' });
Expand Down Expand Up @@ -112,7 +112,7 @@ test('ack watcher - shim', async t => {
*/
test('watcher args arity - shim', async t => {
const zone = makeHeapZone();
const { watch, when, makeVowKit } = prepareVowTools(zone);
const { watch, when, makeVowKit } = prepareBasicVowTools(zone);
const makeArityCheckWatcher = prepareArityCheckWatcher(zone, t);

const testCases = /** @type {const} */ ({
Expand Down Expand Up @@ -173,7 +173,7 @@ test('watcher args arity - shim', async t => {

test('vow self resolution', async t => {
const zone = makeHeapZone();
const { watch, when, makeVowKit } = prepareVowTools(zone);
const { watch, when, makeVowKit } = prepareBasicVowTools(zone);

// A direct self vow resolution
const { vow: vow1, resolver: resolver1 } = makeVowKit();
Expand Down Expand Up @@ -226,7 +226,7 @@ test('vow self resolution', async t => {

test('disconnection of non-vow informs watcher', async t => {
const zone = makeHeapZone();
const { watch, when } = prepareVowTools(zone, {
const { watch, when } = prepareBasicVowTools(zone, {
isRetryableReason: reason => reason === 'disconnected',
});

Expand Down

0 comments on commit 63f0294

Please sign in to comment.