Skip to content

Commit

Permalink
fix: rename producePromise to makePromiseKit (#1329)
Browse files Browse the repository at this point in the history
* fix: rename producePromise to makePromiseKit

* fix: add timeout to spawner test because of appveyor madness

* fix: oops. add @deprecated tag
  • Loading branch information
erights authored Aug 3, 2020
1 parent d582c79 commit 1d2925a
Show file tree
Hide file tree
Showing 51 changed files with 435 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
run: cd packages/notifier && yarn test
- name: yarn test (produce-promise)
run: cd packages/produce-promise && yarn test
- name: yarn test (promise-kit)
run: cd packages/promise-kit && yarn test
- name: yarn test (registrar)
run: cd packages/registrar && yarn test
- name: yarn test (same-structure)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"packages/bundle-source",
"packages/import-bundle",
"packages/eventual-send",
"packages/produce-promise",
"packages/producePromise",
"packages/promise-kit",
"packages/transform-eventual-send",
"packages/tame-metering",
"packages/transform-metering",
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@agoric/layer-cake": "^0.0.1",
"@agoric/marshal": "^0.2.3",
"@agoric/nat": "^2.0.1",
"@agoric/produce-promise": "^0.1.3",
"@agoric/promise-kit": "^0.1.3",
"@agoric/same-structure": "^0.0.8",
"@agoric/store": "^0.2.0",
"@agoric/weak-store": "^0.0.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { assert, details } from '@agoric/assert';
import makeStore from '@agoric/weak-store';
import { isPromise } from '@agoric/produce-promise';
import { isPromise } from '@agoric/promise-kit';

import makeAmountMath from './amountMath';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@agoric/import-bundle": "^0.0.8",
"@agoric/marshal": "^0.2.3",
"@agoric/nat": "^2.0.1",
"@agoric/produce-promise": "^0.1.3",
"@agoric/promise-kit": "^0.1.3",
"@agoric/store": "^0.2.0",
"@agoric/swing-store-simple": "^0.2.3",
"@agoric/tame-metering": "^1.2.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/devices/command.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Nat from '@agoric/nat';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

export default function buildCommand(broadcastCallback) {
if (!broadcastCallback) {
Expand All @@ -14,7 +14,7 @@ export default function buildCommand(broadcastCallback) {
// deliver the JSON-serializable object to the registered handler, and
// return a promise that fires with a JSON-serializable object in
// response
const { promise, resolve, reject } = producePromise();
const { promise, resolve, reject } = makePromiseKit();
const count = nextCount;
nextCount += 1;
responses.set(count, { resolve, reject });
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
makeMarshal,
} from '@agoric/marshal';
import { assert, details } from '@agoric/assert';
import { isPromise } from '@agoric/produce-promise';
import { isPromise } from '@agoric/promise-kit';
import { insistVatType, makeVatSlot, parseVatSlot } from '../parseVatSlots';
import { insistCapData } from '../capdata';

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/kernel/vatAdmin/vatAdminWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* must ensure that only data goes in and out. It's also responsible for turning
* device affordances into objects that can be used by code in other vats.
*/
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

function producePRR() {
const { promise, resolve, reject } = producePromise();
const { promise, resolve, reject } = makePromiseKit();
return [promise, { resolve, reject }];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/vats/network/internal-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

/**
* @template T
* @typedef {import('@agoric/produce-promise').PromiseRecord<T>} PromiseRecord
* @typedef {import('@agoric/promise-kit').PromiseRecord<T>} PromiseRecord
*/
4 changes: 2 additions & 2 deletions packages/SwingSet/src/vats/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import makeStore from '@agoric/store';
import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';
import { toBytes } from './bytes';

import './types';
Expand Down Expand Up @@ -77,7 +77,7 @@ export const makeConnection = (
throw closed;
}
const bytes = toBytes(data);
const ackDeferred = producePromise();
const ackDeferred = makePromiseKit();
pendingAcks.add(ackDeferred);
E(handler)
.onReceive(connection, bytes, handler)
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/vats/vat-tp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { assert, details } from '@agoric/assert';
import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

// See ../../docs/delivery.md for a description of the architecture of the
// comms system.
Expand Down Expand Up @@ -80,7 +80,7 @@ export function buildRootObject(vatPowers) {
const {
promise: theirLocatorUnum,
resolve: gotTheirLocatorUnum,
} = producePromise();
} = makePromiseKit();
const name = makeConnectionName();
let openCalled = false;
assert(!connectionNames.has(name), `already have host for ${name}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/waitUntilQuiescent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global */
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

// This can only be imported from the Start Compartment, where 'setImmediate'
// is available.
Expand All @@ -11,7 +11,7 @@ export function waitUntilQuiescent() {
// lower-priority than the Promise queue on browsers and Node 11, but on
// Node 10 it is higher. So this trick requires Node 11.
// https://jsblog.insiderattack.net/new-changes-to-timers-and-microtasks-from-node-v11-0-0-and-above-68d112743eb3
const { promise: queueEmptyP, resolve } = producePromise();
const { promise: queueEmptyP, resolve } = makePromiseKit();
setImmediate(() => resolve());
return queueEmptyP;
}
4 changes: 2 additions & 2 deletions packages/SwingSet/test/basedir-promises-2/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* global harden */

import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

export function buildRootObject(vatPowers) {
const log = vatPowers.testLog;
return harden({
bootstrap(argv, vats) {
const mode = argv[0];
if (mode === 'harden-promise-1') {
const { promise: p1 } = producePromise();
const { promise: p1 } = makePromiseKit();
harden(p1);
const allP = [];
// in bug #95, this first call returns a (correctly) frozen Promise,
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/basedir-promises/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global harden */

import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

export function buildRootObject(vatPowers) {
const log = vatPowers.testLog;
Expand Down Expand Up @@ -56,7 +56,7 @@ export function buildRootObject(vatPowers) {
return 3;
},
});
const { promise: p1, resolve: r1 } = producePromise();
const { promise: p1, resolve: r1 } = makePromiseKit();
console.log(`here1`, Object.isFrozen(p1));
const p2 = E(vats.left).takePromise(p1);
console.log(`here2`);
Expand Down
20 changes: 10 additions & 10 deletions packages/SwingSet/test/message-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// test.stuff patterns.

import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

// Exercise a set of increasingly complex object-capability message patterns,
// for testing.
Expand Down Expand Up @@ -238,7 +238,7 @@ export function buildPatterns(log) {
const data = await ret.promise;
log(`a50 done, got ${data}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b50 = async () => {
p1.resolve('data');
return harden({ promise: p1.promise });
Expand All @@ -256,7 +256,7 @@ export function buildPatterns(log) {
const bert2 = await E(b.bob).b51_2();
log(`a51 done, got ${bert}, match ${bert === bert2} ${bert === b.bert}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b51 = async () => {
p1.resolve(b.bert);
return harden({ promise: p1.promise });
Expand All @@ -277,7 +277,7 @@ export function buildPatterns(log) {
const bill2 = await E(b.bob).b52_2();
log(`a52 done, got ${bill}, match ${bill === bill2}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b52 = async () => {
p1.resolve(b.bill);
return harden({ promise: p1.promise });
Expand All @@ -296,7 +296,7 @@ export function buildPatterns(log) {
const amy2 = await ret.promise;
log(`a53 done, match ${amy2 === a.amy}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b53 = async amy => {
p1.resolve(amy);
return harden({ promise: p1.promise });
Expand All @@ -308,7 +308,7 @@ export function buildPatterns(log) {
// bob!x(P(amy)) -> amy // resolve after sending
{
objA.a60 = async () => {
const p1 = producePromise();
const p1 = makePromiseKit();
const p2 = E(b.bob).b60({ promise: p1.promise });
p1.resolve(a.amy);
const amy2 = await p2;
Expand Down Expand Up @@ -346,7 +346,7 @@ export function buildPatterns(log) {
const bill = await p2.promise;
log(`a62 done, got ${bill}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b62_1 = async () => {
return { promise: p1.promise };
};
Expand All @@ -365,7 +365,7 @@ export function buildPatterns(log) {
const amy2 = await p2.promise;
log(`a63 done, match ${amy2 === a.amy}`);
};
const p1 = producePromise();
const p1 = makePromiseKit();
let amyOnBob;
objB.b63_1 = async amy2 => {
amyOnBob = amy2;
Expand Down Expand Up @@ -431,7 +431,7 @@ export function buildPatterns(log) {
p3.then(_ => log('p3.then'));
E(b.bob).b71_resolvex();
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b71_getpx = async () => p1.promise;
objB.b71_resolvex = async () => {
const x = harden({
Expand Down Expand Up @@ -481,7 +481,7 @@ export function buildPatterns(log) {
.b72_wait()
.then(() => E(b.bob).b72_resolvex());
};
const p1 = producePromise();
const p1 = makePromiseKit();
objB.b72_wait = async () => 0;
objB.b72_getpx = async () => p1.promise;
objB.b72_resolvex = async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/SwingSet/test/test-marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses';
import { test } from 'tape-promise/tape';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

import { makeMarshaller } from '../src/kernel/liveSlots';

Expand Down Expand Up @@ -108,7 +108,7 @@ test('serialize promise', async t => {
};

const { m } = makeMarshaller(syscall);
const { promise, resolve } = producePromise();
const { promise, resolve } = makePromiseKit();
t.deepEqual(m.serialize(promise), {
body: '{"@qclass":"slot","index":0}',
slots: ['p+5'],
Expand All @@ -128,7 +128,7 @@ test('serialize promise', async t => {
resolve(5);
t.deepEqual(log, []);

const { promise: pauseP, resolve: pauseRes } = producePromise();
const { promise: pauseP, resolve: pauseRes } = makePromiseKit();
setImmediate(() => pauseRes());
await pauseP;
t.deepEqual(log, [{ result: 'p+5', data: { body: '5', slots: [] } }]);
Expand Down
8 changes: 4 additions & 4 deletions packages/SwingSet/test/test-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses'; // adds 'harden' to global
import { test } from 'tape-promise/tape';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';

import {
parse,
Expand Down Expand Up @@ -80,7 +80,7 @@ test('handled protocol', async t => {
try {
const protocol = makeNetworkProtocol(makeProtocolHandler(t));

const closed = producePromise();
const closed = makePromiseKit();
const port = await protocol.bind('/ibc/*/ordered');
await port.connect(
'/ibc/*/ordered/echo',
Expand Down Expand Up @@ -114,7 +114,7 @@ test('protocol connection listen', async t => {
try {
const protocol = makeNetworkProtocol(makeProtocolHandler(t));

const closed = producePromise();
const closed = makePromiseKit();

const port = await protocol.bind('/net/ordered/ordered/some-portname');

Expand Down Expand Up @@ -226,7 +226,7 @@ test('loopback protocol', async t => {
try {
const protocol = makeNetworkProtocol(makeLoopbackProtocolHandler());

const closed = producePromise();
const closed = makePromiseKit();

const port = await protocol.bind('/loopback/foo');

Expand Down
6 changes: 3 additions & 3 deletions packages/SwingSet/test/test-vpid-liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '@agoric/install-ses';
import { test } from 'tape-promise/tape';

import { E } from '@agoric/eventual-send';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';
import { makeLiveSlots } from '../src/kernel/liveSlots';

const RETIRE_VPIDS = true;
Expand Down Expand Up @@ -194,7 +194,7 @@ async function doVatResolveCase1(t, mode) {
const { log, syscall } = buildSyscall();

function build(_vatPowers) {
const pr = producePromise();
const pr = makePromiseKit();
return harden({
async run(target1, target2) {
const p1 = pr.promise;
Expand Down Expand Up @@ -305,7 +305,7 @@ async function doVatResolveCase23(t, which, mode, stalls) {

function build(_vatPowers) {
let p1;
const pr = producePromise();
const pr = makePromiseKit();
const p0 = pr.promise;
return harden({
promise(p) {
Expand Down
8 changes: 4 additions & 4 deletions packages/agoric-cli/integration-tests/test-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@agoric/install-ses';
import { test } from 'tape-promise/tape';
import fs from 'fs';
import tmp from 'tmp';
import { producePromise } from '@agoric/produce-promise';
import { makePromiseKit } from '@agoric/promise-kit';
import { request } from 'http';

import { spawn } from 'child_process';
Expand Down Expand Up @@ -101,7 +101,7 @@ test('workflow', async t => {

// ==============
// agoric start --reset
const startResult = producePromise();
const startResult = makePromiseKit();

// TODO: Allow this to work even if the port is already used.
const startP = myMain(['start', '--reset']);
Expand All @@ -128,7 +128,7 @@ test('workflow', async t => {

// ==============
// agoric deploy ./contract/deploy.js ./api/deploy.js
const deployResult = producePromise();
const deployResult = makePromiseKit();
const deployP = myMain([
'deploy',
`--hostport=127.0.0.1:${PORT}`,
Expand Down Expand Up @@ -182,7 +182,7 @@ test('workflow', async t => {
detached: true,
});
finalizers.push(() => pkill(uiStartP.cp, 'SIGINT'));
const uiListening = producePromise();
const uiListening = makePromiseKit();
let retries = 0;
const ival = setInterval(() => {
try {
Expand Down
Loading

0 comments on commit 1d2925a

Please sign in to comment.