Skip to content

Commit

Permalink
test: upgrade zoe; reproduce smartWallet bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 21, 2023
1 parent 5bf1757 commit e12a96b
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/vats/test/bootstrapTests/test-wallet-upgrade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { E } from '@endo/far';
import { eventLoopIteration } from '@agoric/notifier/tools/testSupports.js';
import { makeAgoricNamesRemotesFromFakeStorage } from '../../tools/board-utils.js';
import { makeWalletFactoryDriver } from './drivers.js';
Expand Down Expand Up @@ -44,11 +45,40 @@ const makeTestContext = async t => {

return {
walletFactoryDriver,
runUtils,
};
};

test.before(async t => (t.context = await makeTestContext(t)));

const upgradeZoeScript = () => {
/**
* @param {VatAdminSvc} vatAdminSvc
* @param {any} adminNode
* @param {string} bundleCapName
* @param {unknown} vatParameters
*/
const upgradeVat = async (
vatAdminSvc,
adminNode,
bundleCapName,
vatParameters = {},
) => {
const bcap = await E(vatAdminSvc).getNamedBundleCap(bundleCapName);
const options = { vatParameters };
const incarnationNumber = await E(adminNode).upgrade(bcap, options);
console.log('upgraded', bundleCapName, 'to', incarnationNumber);
};

const upgradeZoe = async powers => {
const { vatStore, vatAdminSvc } = powers.consume;
const { adminNode } = await E(vatStore).get('zoe');
console.log('zoe admin node', adminNode);
await upgradeVat(vatAdminSvc, adminNode, 'zoe');
};
return upgradeZoe;
};

test('update purse balance across upgrade', async t => {
const oraAddr = 'agoric1oracle-operator';
const { walletFactoryDriver } = t.context;
Expand All @@ -58,6 +88,33 @@ test('update purse balance across upgrade', async t => {
t.truthy(oraWallet);

t.log('upgrade zoe');
t.log('launching proposal');
const proposal = {
evals: [
{
json_permits: JSON.stringify({
consume: { vatStore: true, vatAdminSvc: true },
}),
js_code: `(${upgradeZoeScript})()`,
},
],
};
const bridgeMessage = {
type: 'CORE_EVAL',
evals: proposal.evals,
};
t.log({ bridgeMessage });
const { EV } = t.context.runUtils;
/** @type {ERef<import('../../src/types.js').BridgeHandler>} */
const coreEvalBridgeHandler = await EV.vat('bootstrap').consumeItem(
'coreEvalBridgeHandler',
);
await EV(coreEvalBridgeHandler).fromBridge(bridgeMessage);

// XXX can we test the messages that went to the vat console?
// agoric1oracle-operator failed updateState observer (RemoteError#1)
// RemoteError#1: vat terminated

t.log(
'start a new fluxAggregator for something like stATOM, using the address from 1 as one of the oracleAddresses',
);
Expand Down

0 comments on commit e12a96b

Please sign in to comment.