-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(a3p): test evalBundle after genesis-test
- Loading branch information
1 parent
d6a7ffb
commit 3695ed5
Showing
5 changed files
with
115 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
56
packages/vats/src/proposals/upgrade-mintHolder-proposal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | ||
}); |