-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c27cc4f
commit d4640fa
Showing
8 changed files
with
131 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/bash | ||
|
||
yarn ava replaceFeeDistributor.test.js | ||
yarn ava upgradedBoard.test.js |
14 changes: 14 additions & 0 deletions
14
a3p-integration/proposals/p:upgrade-19/upgradedBoard.test.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,14 @@ | ||
/* eslint-env node */ | ||
// @ts-check | ||
|
||
/** @file test that the upgraded board can store and retrieve values. */ | ||
|
||
import '@endo/init/legacy.js'; | ||
import test from 'ava'; | ||
import { evalBundles } from '@agoric/synthetic-chain'; | ||
|
||
test('test upgraded board', async t => { | ||
await evalBundles('submission'); | ||
|
||
t.pass(); | ||
}); |
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,15 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForTestUpgradedBoard } from '@agoric/vats/src/proposals/testUpgradedBoard.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async () => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/testUpgradedBoard.js', | ||
getManifestCall: [getManifestForTestUpgradedBoard.name], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('testUpgradedBoard', defaultProposalBuilder); | ||
}; |
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 { getManifestForUpgradingBoard } from '@agoric/vats/src/proposals/upgrade-board-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-board-proposal.js', | ||
getManifestCall: [ | ||
getManifestForUpgradingBoard.name, | ||
{ | ||
boardRef: publishRef(install('@agoric/vats/src/vat-board.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-board', defaultProposalBuilder); | ||
}; |
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,35 @@ | ||
import { E, Far } from '@endo/far'; | ||
import { Stable } from '@agoric/internal/src/tokens.js'; | ||
|
||
export const testUpgradedBoard = async ({ | ||
consume: { board }, | ||
brand: { | ||
consume: { [Stable.symbol]: stableBrandP }, | ||
}, | ||
}) => { | ||
// /////// can we store something and get it back? //////// | ||
const thing1 = Far('thing1', {}); | ||
const thing1Id = await E(board).getId(thing1); | ||
assert(thing1Id.match(/^board0[0-9]+$/)); | ||
|
||
// /////// can we retrieve something stored long ago? //////// | ||
const marshaller = await E(board).getReadonlyMarshaller(); | ||
assert(marshaller, 'expected a marshaller'); | ||
|
||
const stableBrand = await stableBrandP; | ||
// /////// can we retrieve a well-known object via its ID? //////// | ||
const stableID = await E(board).getId(stableBrand); | ||
const stableBrandRetrieved = await E(board).getValue(stableID); | ||
assert(stableBrandRetrieved === stableBrand, 'retrieved matching brand'); | ||
}; | ||
|
||
export const getManifestForTestUpgradedBoard = () => ({ | ||
manifest: { | ||
[testUpgradedBoard.name]: { | ||
consume: { board: true }, | ||
brand: { | ||
consume: { [Stable.symbol]: true }, | ||
}, | ||
}, | ||
}, | ||
}); |
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,41 @@ | ||
import { E } from '@endo/far'; | ||
|
||
/** | ||
* @param {BootstrapPowers & { | ||
* consume: { | ||
* vatAdminSvc: VatAdminSvc; | ||
* vatStore: MapStore< | ||
* string, | ||
* import('@agoric/swingset-vat').CreateVatResults | ||
* >; | ||
* }; | ||
* }} powers | ||
* @param {object} options | ||
* @param {{ boardRef: VatSourceRef }} options.options | ||
*/ | ||
export const upgradeBoard = async ( | ||
{ consume: { vatAdminSvc, vatStore } }, | ||
options, | ||
) => { | ||
const { boardRef } = options.options; | ||
|
||
assert(boardRef.bundleID); | ||
const boardBundleCap = await E(vatAdminSvc).getBundleCap(boardRef.bundleID); | ||
console.log(`Board BUNDLE ID: `, boardRef.bundleID); | ||
|
||
const { adminNode } = await E(vatStore).get('board'); | ||
|
||
await E(adminNode).upgrade(boardBundleCap, {}); | ||
}; | ||
|
||
export const getManifestForUpgradingBoard = (_powers, { boardRef }) => ({ | ||
manifest: { | ||
[upgradeBoard.name]: { | ||
consume: { | ||
vatAdminSvc: 'vatAdminSvc', | ||
vatStore: 'vatStore', | ||
}, | ||
}, | ||
}, | ||
options: { boardRef }, | ||
}); |