Skip to content

Commit

Permalink
test(a3p): test evalBundle after genesis-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Dec 4, 2024
1 parent d6a7ffb commit 3695ed5
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 18 deletions.
18 changes: 18 additions & 0 deletions a3p-integration/proposals/z:acceptance/bundle.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import test from 'ava';
import { evalBundles, getIncarnation } from '@agoric/synthetic-chain';

test('Core-eval should pass after genesis test', async t => {
const dir = 'upgrade-mintHolder';

const incarnationBefore = await getIncarnation('BLD');

await evalBundles(dir);

const incarnationAfter = await getIncarnation('BLD');

t.is(
incarnationAfter,
incarnationBefore + 1,
'BLD vat incarnation should increase by 1',
);
});
3 changes: 2 additions & 1 deletion a3p-integration/proposals/z:acceptance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"sdk-generate": [
"testing/start-valueVow.js start-valueVow",
"vats/test-localchain.js localchaintest-submission",
"testing/restart-valueVow.js restart-valueVow"
"testing/restart-valueVow.js restart-valueVow",
"testing/upgrade-mintHolder.js upgrade-mintHolder"
]
},
"type": "module",
Expand Down
36 changes: 19 additions & 17 deletions a3p-integration/proposals/z:acceptance/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ set -ueo pipefail
# The effects of this step are not persisted in further proposal layers.

# test the state right after the previous proposals
yarn ava initial.test.js
# yarn ava initial.test.js

# XXX some of these tests have path dependencies so no globs
yarn ava core-eval.test.js
# # XXX some of these tests have path dependencies so no globs
# yarn ava core-eval.test.js

scripts/test-vaults.ts
# scripts/test-vaults.ts

echo ACCEPTANCE TESTING kread
yarn ava kread.test.js
# echo ACCEPTANCE TESTING kread
# yarn ava kread.test.js

echo ACCEPTANCE TESTING valueVow
yarn ava valueVow.test.js
# echo ACCEPTANCE TESTING valueVow
# yarn ava valueVow.test.js

echo ACCEPTANCE TESTING state sync
./state-sync-snapshots-test.sh
# ./state-sync-snapshots-test.sh
./genesis-test.sh

echo ACCEPTANCE TESTING wallet
yarn ava wallet.test.js
yarn ava bundle.test.js

echo ACCEPTANCE TESTING psm
yarn ava psm.test.js
# echo ACCEPTANCE TESTING wallet
# yarn ava wallet.test.js

echo ACCEPTANCE TESTING governance
yarn ava governance.test.js
# echo ACCEPTANCE TESTING psm
# yarn ava psm.test.js

echo ACCEPTANCE TESTING vaults
yarn ava vaults.test.js
# echo ACCEPTANCE TESTING governance
# yarn ava governance.test.js

# echo ACCEPTANCE TESTING vaults
# yarn ava vaults.test.js
20 changes: 20 additions & 0 deletions packages/builders/scripts/testing/upgrade-mintHolder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { getManifestForUpgradingMintHolder } from '@agoric/vats/src/proposals/upgrade-mintHolder-proposal.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: '@agoric/vats/src/proposals/upgrade-mintHolder-proposal.js',
getManifestCall: [
getManifestForUpgradingMintHolder.name,
{
contractRef: publishRef(install('@agoric/vats/src/mintHolder.js')),
},
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('upgrade-mintHolder-atom', defaultProposalBuilder);
};
56 changes: 56 additions & 0 deletions packages/vats/src/proposals/upgrade-mintHolder-proposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { makeTracer } from '@agoric/internal';
import { E } from '@endo/far';

const trace = makeTracer('upgrade mintHolder BLD', true);

export const upgradeMintHolder = async (
{
consume: {
contractKits: contractKitsP,
instancePrivateArgs: instancePrivateArgsP,
},
},
options,
) => {
trace('Start contract upgrade');

const { contractRef } = options.options;
assert(contractRef.bundleID, 'mintHolder bundleID not found');

const [contractKits, instancePrivateArgs] = await Promise.all([
contractKitsP,
instancePrivateArgsP,
]);

const mintHolderKit = Array.from(contractKits.values()).filter(
kit => kit.label && kit.label.match(/BLD/),
);
assert(mintHolderKit, ',mintHolder contract kit not found');

const { adminFacet, instance } = mintHolderKit[0];

const privateArgs = instancePrivateArgs.get(instance);

const upgradeResult = await E(adminFacet).upgradeContract(
contractRef.bundleID,
privateArgs,
);
trace('upgradeResult: ', upgradeResult);

trace('Finished contract upgrade');
};

export const getManifestForUpgradingMintHolder = (
_powers,
{ contractRef },
) => ({
manifest: {
[upgradeMintHolder.name]: {
consume: {
contractKits: true,
instancePrivateArgs: true,
},
},
},
options: { contractRef },
});

0 comments on commit 3695ed5

Please sign in to comment.