Skip to content

Commit

Permalink
test(vow): add test for resolving vow to external promise
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman authored and michaelfig committed Jun 12, 2024
1 parent d7135b2 commit 99fccca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/SwingSet/tools/bootstrap-relay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assert } from '@agoric/assert';
import { objectMap } from '@agoric/internal';
import { Far, E } from '@endo/far';
import { makePromiseKit } from '@endo/promise-kit';
import { buildManualTimer } from './manual-timer.js';

const { Fail, quote: q } = assert;
Expand Down Expand Up @@ -80,6 +81,12 @@ export const buildRootObject = () => {
return remotable;
},

makePromiseKit: () => {
const { promise, ...resolverMethods } = makePromiseKit();
const resolver = Far('resolver', resolverMethods);
return harden({ promise, resolver });
},

/**
* Returns a copy of a remotable's logs.
*
Expand Down
8 changes: 8 additions & 0 deletions packages/boot/test/upgrading/upgrade-vats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ test('upgrade vat-vow', async t => {
promiseFulfilled: ['hello'],
promiseRejected: ['goodbye', true],
};
const promiseKit = await EV.vat('bootstrap').makePromiseKit();
const localVows = {
vowForever: [],
vowFulfilled: ['hello'],
vowRejected: ['goodbye', true],
vowPostUpgrade: [],
vowExternalPromise: [promiseKit.promise],
vowPromiseForever: [undefined, false, true],
};
await EV(vowRoot).makeLocalPromiseWatchers(localPromises);
Expand All @@ -496,6 +498,10 @@ test('upgrade vat-vow', async t => {
status: 'unsettled',
resolver: {},
},
vowExternalPromise: {
status: 'unsettled',
resolver: {},
},
vowPromiseForever: {
status: 'unsettled',
resolver: {},
Expand All @@ -512,6 +518,7 @@ test('upgrade vat-vow', async t => {
vowPostUpgrade: ['bonjour'],
};
await EV(vowRoot).resolveVowWatchers(localVowsUpdates);
await EV(promiseKit.resolver).resolve('ciao');
t.deepEqual(dataOnly(await EV(vowRoot).getWatcherResults()), {
promiseForever: {
status: 'rejected',
Expand All @@ -530,6 +537,7 @@ test('upgrade vat-vow', async t => {
vowFulfilled: { status: 'fulfilled', value: 'hello' },
vowRejected: { status: 'rejected', reason: 'goodbye' },
vowPostUpgrade: { status: 'fulfilled', value: 'bonjour' },
vowExternalPromise: { status: 'fulfilled', value: 'ciao' },
vowPromiseForever: {
status: 'rejected',
reason: {
Expand Down

0 comments on commit 99fccca

Please sign in to comment.