Skip to content

Commit

Permalink
add jsdoc to script and comment out upgrade swingset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandelis Symeonidis committed Dec 14, 2023
1 parent 5be2e35 commit 5a4da61
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 37 deletions.
10 changes: 10 additions & 0 deletions agoric/contract/scripts/installBundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ const makeFeeObject = ({ denom, amount, gas }) => ({
gas: gas ? String(gas) : 'auto',
});

/**
* Gets the wallet from the mnemonic and uses it to connect to the chain using a stargate client
*
* @param {string} walletMnemonic the mnemonic of the wallet that signs the transaction
* @returns A stargate client
*/
const initializeStargateClient = async (walletMnemonic) => {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(walletMnemonic, {
prefix: Agoric.Bech32MainPrefix,
Expand All @@ -42,6 +48,10 @@ const initializeStargateClient = async (walletMnemonic) => {
});
};

/**
* Parse bundle, get wallet and send transaction
* over stargate to install the bundle on chain
*/
async function installBundle() {
const cosmicSwingsetPath = process.argv[2];
const bundlePath = process.argv[3];
Expand Down
2 changes: 1 addition & 1 deletion agoric/contract/test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const bootstrapContext = async (conf = undefined) => {

const timerService = buildManualTimer();
// Bundle and install contract
const contractBundle = await bundleSource('./src/kreadV1/index.js');
const contractBundle = await bundleSource('./src/index.js');
const installation = await E(zoe).install(contractBundle);
const privateArgs = {
powers: {
Expand Down
2 changes: 1 addition & 1 deletion agoric/contract/test/flow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { errors } from '../src/kreadV2/errors.js';
import { errors } from '../src/errors.js';
import { text } from './text.js';
import { defaultItems } from './items.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { flow } from '../flow.js';
import { E } from '@endo/eventual-send';
import { makeCopyBag, mustMatch } from '@agoric/store';
import { AmountMath } from '@agoric/ertp';
import { errors } from '../../../src/kreadV2/errors.js';
import { errors } from '../../../src/errors.js';

export async function setupInventoryTests(context) {
await addCharacterToContext(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { flow } from '../flow.js';
import { makeCopyBag, mustMatch } from '@agoric/store';
import { addCharacterToContext, addItemToContext } from './utils.js';
import { makeKreadUser } from './make-bootstrap-users.js';
import { errors } from '../../../src/kreadV2/errors.js';
import { errors } from '../../../src/errors.js';
import { multiplyBy } from '@agoric/zoe/src/contractSupport/ratio.js';
import { defaultItems } from '../items.js';
import { TimerBrandShape } from '@agoric/time';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import { mint } from './bootstrap-null-upgrade.js';
const trace = makeTracer('kreadBootUpgrade');

const kreadV1BundleName = 'kreadV1';
const kreadV2BundleName = 'kreadV2';
// const kreadV2BundleName = 'kreadV2';

export const buildRootObject = async () => {
let vatAdmin;
Expand All @@ -85,7 +85,7 @@ export const buildRootObject = async () => {
let governedInstance;
/** @type {Context} */
let context;
/** @type {import('@agoric/governance/tools/puppetContractGovernor').PuppetContractGovernorKit<import('../../../src/kreadV2/index.js').prepare>} */
/** @type {import('@agoric/governance/tools/puppetContractGovernor').PuppetContractGovernorKit<import('../../../src/index.js').prepare>} */
let governorFacets;

const storageKit = makeFakeStorageKit('kread');
Expand Down Expand Up @@ -492,16 +492,16 @@ export const buildRootObject = async () => {
assert.equal(upgradeResult.incarnationNumber, 1);
trace('null upgrade completed');
},
upgradeV2: async () => {
const bundleId = await E(vatAdmin).getBundleIDByName(kreadV2BundleName);
const kreadAdminFacet = await E(
governorFacets.creatorFacet,
).getAdminFacet();
const upgradeResult = await E(kreadAdminFacet).upgradeContract(bundleId, {
...staticPrivateArgs,
initialPoserInvitation,
});
},
// upgradeV2: async () => {
// const bundleId = await E(vatAdmin).getBundleIDByName(kreadV2BundleName);
// const kreadAdminFacet = await E(
// governorFacets.creatorFacet,
// ).getAdminFacet();
// const upgradeResult = await E(kreadAdminFacet).upgradeContract(bundleId, {
// ...staticPrivateArgs,
// initialPoserInvitation,
// });
// },
testFunctionalityBeforeUpgrade: async () => {
await testFunctionalityBeforeUpgrade(context);
},
Expand Down
2 changes: 1 addition & 1 deletion agoric/contract/test/swingsetTests/flow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { errors } from '../../src/kreadV2/errors.js';
import { errors } from '../../src/errors.js';
import { text } from './text.js';
import { defaultItems } from './items.js';

Expand Down
16 changes: 8 additions & 8 deletions agoric/contract/test/swingsetTests/swingset-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { assert } from '@agoric/assert';

const bfile = (name) => new URL(name, import.meta.url).pathname;
const kreadV1BundleName = 'kreadV1';
const kreadV2BundleName = 'kreadV2';
// const kreadV2BundleName = 'kreadV2';

let c;

Expand Down Expand Up @@ -66,16 +66,16 @@ export async function setup() {
},
[kreadV1BundleName]: {
sourceSpec: await importMetaResolve(
'../../src/kreadV1/index.js',
import.meta.url,
).then((href) => new URL(href).pathname),
},
[kreadV2BundleName]: {
sourceSpec: await importMetaResolve(
'../../src/kreadV2/index.js',
'../../src/index.js',
import.meta.url,
).then((href) => new URL(href).pathname),
},
// [kreadV2BundleName]: {
// sourceSpec: await importMetaResolve(
// '../../src/kreadV2/index.js',
// import.meta.url,
// ).then((href) => new URL(href).pathname),
// },
},
};

Expand Down
18 changes: 9 additions & 9 deletions agoric/contract/test/swingsetTests/test-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ test.serial('test functionality before upgrade', async (t) => {
t.is(result, 'fulfilled');
});

test.serial('upgrade to V2', async (t) => {
const [result] = await run('upgradeV2');
t.is(result, 'fulfilled');
});
// test.serial('upgrade to V2', async (t) => {
// const [result] = await run('upgradeV2');
// t.is(result, 'fulfilled');
// });

test.serial('test functionality after upgrade', async (t) => {
const [result] = await run('testFunctionalityAfterUpgrade');
t.is(result, 'fulfilled');
});
// test.serial('test functionality after upgrade', async (t) => {
// const [result] = await run('testFunctionalityAfterUpgrade');
// t.is(result, 'fulfilled');
// });

// test.serial()
// // test.serial()
2 changes: 1 addition & 1 deletion agoric/contract/test/swingsetTests/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
* creatorFacet: unknown;
* contractAssets: ContractAssets;
* publicFacet: unknown;
* governorFacets: import('@agoric/governance/tools/puppetContractGovernor').PuppetContractGovernorKit<import('../../src/kreadV2/index.js').prepare>;
* governorFacets: import('@agoric/governance/tools/puppetContractGovernor').PuppetContractGovernorKit<import('../../src/index.js').prepare>;
* zoe: ZoeService;
* purses: {
* character: any
Expand Down
2 changes: 1 addition & 1 deletion agoric/contract/test/test-inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { bootstrapContext } from './bootstrap.js';
import { flow } from './flow.js';
import { addCharacterToBootstrap, addItemToBootstrap } from './setup.js';
import { makeCopyBag } from '@agoric/store';
import { errors } from '../src/kreadV2/errors.js';
import { errors } from '../src/errors.js';

test.before(async (t) => {
const bootstrap = await bootstrapContext();
Expand Down
2 changes: 1 addition & 1 deletion agoric/contract/test/test-market.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { flow } from './flow.js';
import { makeKreadUser } from './make-user.js';
import { addCharacterToBootstrap, addItemToBootstrap } from './setup.js';
import { makeCopyBag } from '@agoric/store';
import { errors } from '../src/kreadV2/errors.js';
import { errors } from '../src/errors.js';
import { defaultItems } from './items.js';
import { multiplyBy } from '@agoric/zoe/src/contractSupport/ratio.js';

Expand Down

0 comments on commit 5a4da61

Please sign in to comment.