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 25, 2024
1 parent 6c15cc9 commit 9300ae8
Show file tree
Hide file tree
Showing 2 changed files with 67 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
65 changes: 65 additions & 0 deletions packages/vow/test/watch-upgrade.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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);
// We're only preparing the watcher exo with new behavior. The instance is
// already attached as a watcher for the test vow
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 testVowKitResolver = zone.makeOnce('testVowKit', () => {
t.fail('testVowKit maker called');
}).resolver;

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

0 comments on commit 9300ae8

Please sign in to comment.