diff --git a/a3p-integration/proposals/p:upgrade-19/agoricNames.test.js b/a3p-integration/proposals/p:upgrade-19/agoricNames.test.js index 545472c83bf..d15a8c3beaa 100644 --- a/a3p-integration/proposals/p:upgrade-19/agoricNames.test.js +++ b/a3p-integration/proposals/p:upgrade-19/agoricNames.test.js @@ -1,7 +1,7 @@ /* eslint-env node */ /** - * @file + * @file * Ideas: * - write something new to agoricNames and check vstorage * - can you add a new chain for orc? @@ -17,10 +17,7 @@ import { agoric, getDetailsMatchingVats, } from '@agoric/synthetic-chain'; -import { - makeVstorageKit, - makeAgoricNames, -} from '@agoric/client-utils'; +import { makeVstorageKit } from '@agoric/client-utils'; const AGORIC_NAMES_UPGRADE_DIR = 'upgradeAgoricNames'; const WRITE_AGORIC_NAMES = 'writeToAgoricNames'; @@ -43,7 +40,7 @@ test.before(async t => { }; }); -test.serial('upgrade agoricNames', async t => { +test.serial.only('upgrade agoricNames', async t => { await evalBundles(AGORIC_NAMES_UPGRADE_DIR); const vatDetailsAfter = await getDetailsMatchingVats('agoricNames'); @@ -57,40 +54,49 @@ test.serial('upgrade agoricNames', async t => { }); test.serial.only('check all existing values are preserved', async t => { - // @ts-expect-error + // @ts-expect-error const { vstorageKit } = t.context; - - const getAgoricNames = () => Promise.all([ - vstorageKit.readLatestHead('published.agoricNames.issuer').then(issuer => Object.fromEntries(issuer)), - vstorageKit.readLatestHead('published.agoricNames.installation').then(installation => Object.fromEntries(installation)), - vstorageKit.readLatestHead('published.agoricNames.oracleBrand').then(oracleBrand => Object.fromEntries(oracleBrand)), - vstorageKit.readLatestHead('published.agoricNames.brand').then(brand => Object.fromEntries(brand)), - vstorageKit.readLatestHead('published.agoricNames.instance').then(instance => Object.fromEntries(instance)), - vstorageKit.readLatestHead('published.agoricNames.vbankAsset').then(vbankAsset => Object.fromEntries(vbankAsset)), - ]).then(([issuer, installation, oracleBrand, brand, instance, vbankAsset]) => ({ issuer, installation, oracleBrand, brand, instance, vbankAsset })); + const agoricNamesChildren = [ + 'brand', + 'installation', + 'instance', + 'issuer', + 'oracleBrand', + 'vbankAsset', + ]; + + const getAgoricNames = () => + Promise.all( + agoricNamesChildren.map(async child => { + const content = await vstorageKit.readLatestHead( + `published.agoricNames.${child}`, + ); + return [child, Object.fromEntries(content)]; + }), + ).then(rawAgoricNames => Object.fromEntries(rawAgoricNames)); const agoricNamesBefore = await getAgoricNames(); console.log('AGORIC_NAMES_BEFORE', agoricNamesBefore); - await evalBundles(WRITE_AGORIC_NAMES); + await evalBundles(WRITE_AGORIC_NAMES); const agoricNamesAfter = await getAgoricNames(); - t.deepEqual(agoricNamesAfter, { - issuer: { ...agoricNamesBefore.issuer, testIssuer: 'testIssuer'}, - installation: { ...agoricNamesBefore.installation, testInstallation: 'testInstallation'}, - oracleBrand: { ...agoricNamesBefore.oracleBrand, testOracleBrand: 'testOracleBrand'}, - brand: { ...agoricNamesBefore.brand, testBrand: 'testBrand'}, - instance: { ...agoricNamesBefore.instance, testInstance: 'testInstance'}, - vbankAsset: { ...agoricNamesBefore.vbankAsset, testAsset: 'testAsset'}, - }); + t.like(agoricNamesAfter, agoricNamesBefore); - t.pass(); + agoricNamesChildren.forEach(child => + assert( + agoricNamesAfter[child][`test${child}`], + 'we should be able to add new value', + ), + ); }); -test.serial.skip('check we can add new chains', async t => { - +test.serial.only('check we can add new chains', async t => { + await evalBundles('chainInfoTest'); + t.pass(); }); -test.serial.skip('check contracts depend on agoricNames are not broken', async t => { - -}); +test.serial.skip( + 'check contracts depend on agoricNames are not broken', + async t => {}, +); diff --git a/a3p-integration/proposals/p:upgrade-19/writeToAgoricNames/write-to-agoricNames.js b/a3p-integration/proposals/p:upgrade-19/writeToAgoricNames/write-to-agoricNames.js index a815190ba87..89b37f95cca 100644 --- a/a3p-integration/proposals/p:upgrade-19/writeToAgoricNames/write-to-agoricNames.js +++ b/a3p-integration/proposals/p:upgrade-19/writeToAgoricNames/write-to-agoricNames.js @@ -1,21 +1,30 @@ // @ts-nocheck +/* eslint-disable no-undef */ const writeToAgoricNames = async powers => { const { - consume: { - agoricNamesAdmin, - } + consume: { agoricNamesAdmin }, } = powers; console.log('writing to agoricNames...'); - await Promise.all([ - E(E(agoricNamesAdmin).lookupAdmin('issuer')).update('testIssuer', 'testIssuer'), - E(E(agoricNamesAdmin).lookupAdmin('brand')).update('testBrand', 'testBrand'), - E(E(agoricNamesAdmin).lookupAdmin('installation')).update('testInstallation', 'testInstallation'), - E(E(agoricNamesAdmin).lookupAdmin('vbankAsset')).update('testAsset', 'testAsset'), - E(E(agoricNamesAdmin).lookupAdmin('instance')).update('testInstance', 'testInstance'), - E(E(agoricNamesAdmin).lookupAdmin('oracleBrand')).update('testOracleBrand', 'testOracleBrand'), - ]); + const agoricNamesChildren = [ + 'brand', + 'installation', + 'instance', + 'issuer', + 'oracleBrand', + 'vbankAsset', + ]; + + await Promise.all( + agoricNamesChildren.map(async (child, index) => + E(E(agoricNamesAdmin).lookupAdmin(child)).update( + `test${child}`, + Far(`test${child}`, { getBoardId: () => `board${index}` }), + ), + ), + ); + console.log('DONE'); }; -writeToAgoricNames; \ No newline at end of file +writeToAgoricNames; diff --git a/packages/builders/scripts/vats/upgrade-agoricNames.js b/packages/builders/scripts/vats/upgrade-agoricNames.js index 375d307368f..80716903a06 100644 --- a/packages/builders/scripts/vats/upgrade-agoricNames.js +++ b/packages/builders/scripts/vats/upgrade-agoricNames.js @@ -7,7 +7,9 @@ export const defaultProposalBuilder = async ({ publishRef, install }) => getManifestCall: [ 'getManifestForUpgradingAgoricNames', { - agoricNamesRef: publishRef(install('@agoric/vats/src/vat-agoricNames.js')), + agoricNamesRef: publishRef( + install('@agoric/vats/src/vat-agoricNames.js'), + ), }, ], });