Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(zone,vow): is this a watch revival bug? #9125

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/zone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
"@endo/pass-style": "^1.2.0"
},
"devDependencies": {
"@agoric/internal": "^0.3.2",
"@agoric/swingset-liveslots": "^0.10.2",
"@agoric/vow": "^0.1.0",
"@endo/patterns": "^1.2.0",
"@endo/promise-kit": "^1.0.4",
"ava": "^5.3.0"
},
"publishConfig": {
Expand Down
101 changes: 101 additions & 0 deletions packages/zone/test/test-upgrade-watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// eslint-disable-next-line import/order
import {
test,
getBaggage,
annihilate,
nextLife,
} from './prepare-test-env-ava.js';

import { Fail } from '@endo/errors';

Check failure on line 9 in packages/zone/test/test-upgrade-watch.js

View workflow job for this annotation

GitHub Actions / lint-rest

'@endo/errors' should be listed in the project's dependencies. Run 'npm i -S @endo/errors' to add it
import { passStyleOf } from '@endo/pass-style';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { PromiseWatcherI } from '@agoric/vow/src/watch-promise.js';
import { makePromiseKit } from '@endo/promise-kit';
// import { prepareVowTools } from '@agoric/vow';
import { prepareVowTools as prepareWatchableVowTools } from '@agoric/vat-data/vow.js';

// import { makeHeapZone } from '../heap.js';
// import { makeVirtualZone } from '../virtual.js';
import { makeDurableZone } from '../durable.js';

/**
* @param {any} t
* @param {import('@agoric/base-zone').Zone} zone
* @param {any} vowTools
*/
const testFirstPlay = async (t, zone, vowTools) => {
const { watch, makeVowKit } = vowTools;

const rupertGiles = zone.exo('RupertGiles', PromiseWatcherI, {
onFulfilled(fulfillment) {
console.log('should not wake yet', fulfillment);
},
onRejected(reason) {
console.log('should not startle yet', reason);
},
});
const { vow: v1 } = zone.makeOnce('v1', () => makeVowKit());
t.is(passStyleOf(v1), 'tagged');

watch(v1, rupertGiles);
};

/**
* @param {any} t
* @param {import('@agoric/base-zone').Zone} zone
* @param {any} _vowTools
*/
const testReplay = async (t, zone, _vowTools) => {
const { promise, resolve, reject } = makePromiseKit();

zone.exo('RupertGiles', PromiseWatcherI, {
onFulfilled(fulfillment) {
console.log('woken', fulfillment);
resolve(fulfillment);
},
onRejected(reason) {
console.log('startled', reason);
reject(reason);
},
});

const { vow: v1, resolver: r1 } =
/** @type {import('@agoric/vow').VowKit} */ (
zone.makeOnce('v1', () => Fail`v1 expected`)
);
t.is(passStyleOf(v1), 'tagged');
console.log('ask to awaken');
r1.resolve('wake up');
const f = await promise;
// BUG? We never get here
console.log('fulfilled', f);
};

// await test.serial('test heap async-flow', async t => {
// const zone = makeHeapZone('heapRoot');
// const vowTools = prepareVowTools(zone);
// return testFirstPlay(t, zone, vowTools);
// });

// await test.serial('test virtual async-flow', async t => {
// annihilate();
// const zone = makeVirtualZone('virtualRoot');
// const vowTools = prepareVowTools(zone);
// return testFirstPlay(t, zone, vowTools);
// });

await test.serial('test durable async-flow', async t => {
annihilate();

nextLife();
const zone1 = makeDurableZone(getBaggage(), 'durableRoot');
const vowTools1 = prepareWatchableVowTools(zone1);
await testFirstPlay(t, zone1, vowTools1);

await eventLoopIteration();

nextLife();
const zone2 = makeDurableZone(getBaggage(), 'durableRoot');
const vowTools2 = prepareWatchableVowTools(zone2);
return testReplay(t, zone2, vowTools2);
});
Loading