Skip to content

Commit

Permalink
test(vow): add fake liveslots upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Sep 21, 2024
1 parent 11171f9 commit e3e99a4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
},
"devDependencies": {
"@agoric/internal": "^0.3.2",
"@agoric/swingset-vat": "^0.32.2",
"@agoric/zone": "^0.2.2",
"@endo/far": "^1.1.5",
"@endo/init": "^1.1.4",
"ava": "^5.3.0",
Expand Down
63 changes: 63 additions & 0 deletions packages/vow/test/watch-upgrade.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
annihilate,
startLife,
test,
} from '@agoric/swingset-vat/tools/prepare-strict-test-env-ava.js';

import { makeDurableZone } from '@agoric/zone/durable.js';

import { prepareVowTools } from '../vat.js';

test.serial('vow resolve across upgrade', async t => {
annihilate();

t.plan(1);

await startLife(async baggage => {
const zone = makeDurableZone(baggage, 'durableRoot');
const vowTools = prepareVowTools(zone);
const watcher = zone.exo('DurableVowTestWatcher', undefined, {
onFulfilled(value) {
t.fail(
`First incarnation watcher onFulfilled triggered with value ${value}`,
);
},
onRejected(reason) {
t.fail(
`First incarnation watcher onRejected triggered with reason ${reason}`,
);
},
});

const testVowKit = zone.makeOnce('testVowKit', () => vowTools.makeVowKit());

vowTools.watch(testVowKit.vow, watcher);
});

await startLife(
baggage => {
const zone = makeDurableZone(baggage, 'durableRoot');
prepareVowTools(zone);
zone.exo('DurableVowTestWatcher', undefined, {
onFulfilled(value) {
t.is(value, 42, 'vow resolved with value 42');
},
onRejected(reason) {
t.fail(
`Second incarnation watcher onRejected triggered with reason ${reason}`,
);
},
});

/** @type {import('../src/types.js').VowResolver} */
const testVowKitResoler = zone.makeOnce('testVowKit', () => {
t.fail('testVowKit maker called');
}).resolver;

return { testVowKitResoler };
},
async ({ testVowKitResoler }) => {
testVowKitResoler.resolve(42);
},
);
});

0 comments on commit e3e99a4

Please sign in to comment.