Skip to content

Commit

Permalink
test: zoe has been upgraded once
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Sep 1, 2023
1 parent a56f0b9 commit 61c8459
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
// @ts-check
import test from 'ava';
import processAmbient from 'process';
import dbOpenAmbient from 'better-sqlite3';

// XXX agd closes over ambient authority: execa, process.env
import { agd as agdAmbient } from '../cliHelper.mjs';
import { extractStreamCellValue, makeBoardMarshaller } from '../boardClient.js';
import { makeSwingstore, swingstorePath } from './tools/swingStore-lite.mjs';

test.before(async t => {
t.context = { agd: agdAmbient };
t.context = {
agd: agdAmbient,
env: { HOME: processAmbient.env.HOME },
dbOpen: dbOpenAmbient,
};
});

const makeBoardClient = agd => {
Expand Down Expand Up @@ -70,3 +77,30 @@ test('IST displayInfo is correct', async t => {
const aux = await bc.get(`published.boardAux.${id}`);
t.deepEqual(aux.displayInfo, { assetKind: AssetKind.NAT, decimalPlaces: 6 });
});

/** @type {<T>(val: T | undefined) => T} */
const NonNullish = val => {
if (!val) throw Error('required');
return val;
};

test('zoe has been upgraded once', async t => {
const {
dbOpen,
env: { HOME },
} = t.context;
const vatName = 'zoe';

const fullPath = swingstorePath.replace(/^~/, NonNullish(HOME));
const kStore = makeSwingstore(dbOpen(fullPath, { readonly: true }));

const vatID = kStore.findVat(vatName);
const vatInfo = kStore.lookupVat(vatID);

const source = vatInfo.source();
const { incarnation } = vatInfo.currentSpan();

t.log({ vatName, vatID, incarnation, ...source });

t.is(incarnation, 1);
});

0 comments on commit 61c8459

Please sign in to comment.