diff --git a/a3p-integration/proposals/z:acceptance/bundle.test.js b/a3p-integration/proposals/z:acceptance/bundle.test.js new file mode 100644 index 00000000000..eaf7e39c55a --- /dev/null +++ b/a3p-integration/proposals/z:acceptance/bundle.test.js @@ -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', + ); +}); diff --git a/a3p-integration/proposals/z:acceptance/package.json b/a3p-integration/proposals/z:acceptance/package.json index 8a906d701b8..e4a672a82e6 100644 --- a/a3p-integration/proposals/z:acceptance/package.json +++ b/a3p-integration/proposals/z:acceptance/package.json @@ -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", diff --git a/a3p-integration/proposals/z:acceptance/test.sh b/a3p-integration/proposals/z:acceptance/test.sh index a029b8d6e8a..24a5054ec84 100755 --- a/a3p-integration/proposals/z:acceptance/test.sh +++ b/a3p-integration/proposals/z:acceptance/test.sh @@ -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 diff --git a/packages/builders/scripts/testing/upgrade-mintHolder.js b/packages/builders/scripts/testing/upgrade-mintHolder.js new file mode 100644 index 00000000000..d70bb15f4b5 --- /dev/null +++ b/packages/builders/scripts/testing/upgrade-mintHolder.js @@ -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); +}; diff --git a/packages/vats/src/proposals/upgrade-mintHolder-proposal.js b/packages/vats/src/proposals/upgrade-mintHolder-proposal.js new file mode 100644 index 00000000000..739fb51cf1d --- /dev/null +++ b/packages/vats/src/proposals/upgrade-mintHolder-proposal.js @@ -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 }, +});