Skip to content

Commit

Permalink
feat: upgrade provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Feb 16, 2024
1 parent bc337b5 commit 19ee116
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! false node --ignore-this-line
/* global E */

/// <reference types="@agoric/vats/src/core/core-eval-env"/>
/// <reference types="@agoric/vats/src/core/types-ambient"/>

/**
* Send a payment by looking up deposit facet via namesByAddress.
*
* see ./post.test.js
*
* @param {BootstrapPowers} powers
*/
const sendIt = async powers => {
const addr = '{{ADDRESS}}';
const {
consume: { namesByAddress, zoe },
instance: {
consume: { reserve },
},
} = powers;
const pf = E(zoe).getPublicFacet(reserve);
const anInvitation = await E(pf).makeAddCollateralInvitation();
const addressDepositFacet = E(namesByAddress).lookup(addr, 'depositFacet');
await E(addressDepositFacet).receive(anInvitation);
};

sendIt;
51 changes: 51 additions & 0 deletions a3p-integration/proposals/a:upgrade-next/provisioning.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// @ts-check

import test from 'ava';
import { readFile, writeFile } from 'node:fs/promises';

import {
getIncarnation,
getUser,
evalBundles,
waitForBlock,
agoric,
} from '@agoric/synthetic-chain';

const SUBMISSION_DIR = 'provisioning-test-submission';

/**
* @param {string} fileName base file name without .tjs extension
* @param {Record<string, string>} replacements
*/
const replaceTemplateValuesInFile = async (fileName, replacements) => {
let script = await readFile(`${fileName}.tjs`, 'utf-8');
for (const [template, value] of Object.entries(replacements)) {
script = script.replaceAll(`{{${template}}}`, value);
}
await writeFile(`${fileName}.js`, script);
};

test(`provisioning vat was upgraded`, async t => {
const incarnation = await getIncarnation('provisioning');

t.is(incarnation, 1);
});

test(`send invitation via namesByAddress`, async t => {
const addr = await getUser('gov1');

await replaceTemplateValuesInFile(`${SUBMISSION_DIR}/send-script`, {
ADDRESS: addr,
});

await evalBundles(SUBMISSION_DIR);

await waitForBlock(2); // enough time for invitation to arrive?
const update = await agoric.follow('-lF', `:published.wallet.${addr}`);
t.is(update.updated, 'balance');
t.notDeepEqual(update.currentAmount.value, []);
t.log('balance value', update.currentAmount.value);
t.log('balance brand', update.currentAmount.brand);
// XXX agoric follow returns brands as strings
t.regex(update.currentAmount.brand, /Invitation/);
});
2 changes: 2 additions & 0 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
vm.CoreProposalStepForModules("@agoric/builders/scripts/smart-wallet/build-wallet-factory2-upgrade.js"),
// Then, upgrade Zoe and ZCF
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-zoe.js"),
// Then, upgrade the provisioning vat
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-provisioning.js"),
// vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/init-network.js"),
}

Expand Down

0 comments on commit 19ee116

Please sign in to comment.