Skip to content

Commit

Permalink
test: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 14, 2024
1 parent b1b1281 commit 386fb5f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 108 deletions.
4 changes: 2 additions & 2 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"make:help": "make list",
"start": "make clean start-contract",
"build": "yarn build:deployer",
"build:deployer": "node --preserve-symlinks ./node_modules/.bin/rollup -c rollup.config.mjs",
"test": "node --preserve-symlinks ./node_modules/.bin/ava --verbose",
"build:deployer": "rollup -c rollup.config.mjs",
"test": "ava",
"lint": "eslint '**/*.js'",
"lint:types": "tsc -p jsconfig.json",
"lint:fix": "eslint --fix '**/*.js'"
Expand Down
101 changes: 36 additions & 65 deletions contract/src/orca.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,26 @@
// import V from '@agoric/vow/src/E.js';
// import { V as _E } from "../../../../agoric-sdk/packages/vow/vat.js"


// import { M, getCopyBagEntries, makeCopyBag } from '@endo/patterns';
import { M } from '@endo/patterns';
import { makeCopyBag, getCopyBagEntries } from '@agoric/store'
import { makeCopyBag, getCopyBagEntries } from '@agoric/store';

Check failure on line 10 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'makeCopyBag' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 10 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'getCopyBagEntries' is defined but never used. Allowed unused vars must match /^_/u
import { AssetKind } from '@agoric/ertp/src/amountMath.js';

Check failure on line 11 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'AssetKind' is defined but never used. Allowed unused vars must match /^_/u
import '@agoric/zoe/exported.js';
import { AmountShape, AmountMath, PaymentShape } from '@agoric/ertp';

Check failure on line 13 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'AmountShape' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 13 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'AmountMath' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 13 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'PaymentShape' is defined but never used. Allowed unused vars must match /^_/u
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';

Check failure on line 14 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'atomicRearrange' is defined but never used. Allowed unused vars must match /^_/u
import { makeMyAddressNameAdminKit } from '@agoric/vats/src/core/utils';
import { makeMyAddressNameAdminKit } from '@agoric/vats/src/core/utils.js';

Check failure on line 15 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'makeMyAddressNameAdminKit' is defined but never used. Allowed unused vars must match /^_/u
// import { makeOnewayPriceAuthorityKit } from '@agoric/zoe/src/contractSupport';
import {
defineERecorderKit,
prepareRecorderKitMakers,
provideAll
defineERecorderKit,

Check failure on line 18 in contract/src/orca.contract.js

View workflow job for this annotation

GitHub Actions / unit

'defineERecorderKit' is defined but never used. Allowed unused vars must match /^_/u
prepareRecorderKitMakers,
provideAll,
} from '@agoric/zoe/src/contractSupport/index.js';
import { handleParamGovernance } from '@agoric/governance/src/contractHelper.js';
import { ParamTypes } from '@agoric/governance/src/constants.js';

import { makeTracer, StorageNodeShape } from '@agoric/internal';
import { makeDurableZone } from '@agoric/zone/durable.js';

// ISSUE IMPORTING THIS, which promted yarn link:
/*
[!] (plugin configureBundleID) TypeError: Failed to load module "./src/orchdev.contract.js" in package "file:///Users/jovonni/Documents/projects/experiments/orca/contract/" (1 underlying failures: Cannot find external module "@agoric/orchestration/src/exos/stakingAccountKit.js" in package file:///Users/jovonni/Documents/projects/experiments/orca/contract/
src/orchdev.proposal.js
*/
import { prepareStakingAccountKit } from '@agoric/orchestration/src/exos/stakingAccountKit.js';




// import { Fail } from '@agoric/assert';
const { Fail } = assert;

import { makeOrchestrationFacade } from './facade.js';
Expand All @@ -52,60 +40,43 @@ const trace = makeTracer('OrchDev1');
*/

export const meta = harden({
privateArgsShape: {
orchestration: M.remotable('orchestration'),
storageNode: StorageNodeShape,
marshaller: M.remotable('Marshaller'),
timer: M.remotable('TimerService'),
},
privateArgsShape: {
orchestration: M.remotable('orchestration'),
storageNode: StorageNodeShape,
marshaller: M.remotable('Marshaller'),
timer: M.remotable('TimerService'),
},
});

export const privateArgsShape = meta.privateArgsShape;


export const terms = harden({

});

export const terms = harden({});

/**
*
* @param {ZCF<StakeAtomTerms>} zcf
* @param {{
* orchestration: OrchestrationService;
* storageNode: StorageNode;
* marshaller: Marshaller;
* timer: TimerService;
* }} privateArgs
* @param {Baggage} baggage
*/
export const start = async (zcf , privateArgs, baggage) => {

console.log("===== CONTRACT STARTING :) ======")
const { hostConnectionId, controllerConnectionId, bondDenom } = zcf.getTerms();
const { orchestration, marshaller, storageNode, timer } = privateArgs;

const zone = makeDurableZone(baggage);

const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);

const makeStakingAccountKit = prepareStakingAccountKit(
baggage,
makeRecorderKit,
zcf,
);

const publicFacet = zone.exo(
'Orca Public Facet',
M.interface('StakeAtomI', {
makeAccount: M.callWhen().returns(M.remotable('ChainAccount')),
makeAcountInvitationMaker: M.call().returns(M.promise()),
}),
{

});

return harden({publicFacet});
}

harden(start)
* orchestration: OrchestrationService;
* storageNode: StorageNode;
* marshaller: Marshaller;
* timer: TimerService;
* }} privateArgs
* @param {Baggage} baggage
*/
export const start = async (zcf, privateArgs, baggage) => {
console.log('===== CONTRACT STARTING :) ======');
const zone = makeDurableZone(baggage);

const publicFacet = zone.exo(
'Orca Public Facet',
M.interface('StakeAtomI', {
makeAccount: M.callWhen().returns(M.remotable('ChainAccount')),
makeAcountInvitationMaker: M.call().returns(M.promise()),
}),
{},
);

return harden({ publicFacet });
};

harden(start);
45 changes: 22 additions & 23 deletions contract/test/test-build-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';
test.before(async t => {
const bundleCache = await makeNodeBundleCache('bundles', {}, s => import(s));

console.log("running..")

console.log('running..');

/**
* @param {string} name of an _already cached_ bundle
Expand All @@ -26,7 +25,7 @@ test.before(async t => {
};

const $ = (file, ...args) => {
console.error(cmd);
// console.error(cmd);

return new Promise((resolve, reject) => {
execFile(file, args, { encoding: 'utf8' }, (err, out) => {
Expand All @@ -51,25 +50,25 @@ test.before(async t => {
t.context = { compressBundle, $, runPackageScript, listBundles };
});

// test('bundles from build:deployer meet 1MB request limit', async t => {
// const { runPackageScript, listBundles, compressBundle } = t.context;
// await runPackageScript('build:deployer');
test('bundles from build:deployer meet 1MB request limit', async t => {
const { runPackageScript, listBundles, compressBundle } = t.context;
await runPackageScript('build:deployer');

// const bundles = await listBundles();
// t.assert(bundles.length, 'Found bundles');
const bundles = await listBundles();
t.assert(bundles.length, 'Found bundles');

// const MB = 1024 * 1024;
// for (const bundleName of bundles) {
// // eslint-disable-next-line @jessie.js/safe-await-separator
// const { bundle, compressed: buffer } = await compressBundle(bundleName);
// t.assert(buffer);
// const sizeInMb = buffer.length / MB;
// // JSON RPC hex encoding doubles the size
// t.assert(sizeInMb * 2 < 1, 'Compressed bundle is less than 0.5MB');
// t.log({
// bundleName,
// compressedSize: `${sizeInMb.toFixed(3)} MB`,
// originallySize: `${(JSON.stringify(bundle).length / MB).toFixed(3)} MB`,
// });
// }
// });
const MB = 1024 * 1024;
for (const bundleName of bundles) {
// eslint-disable-next-line @jessie.js/safe-await-separator
const { bundle, compressed: buffer } = await compressBundle(bundleName);
t.assert(buffer);
const sizeInMb = buffer.length / MB;
// JSON RPC hex encoding doubles the size
t.assert(sizeInMb * 2 < 1, 'Compressed bundle is less than 0.5MB');
t.log({
bundleName,
compressedSize: `${sizeInMb.toFixed(3)} MB`,
originallySize: `${(JSON.stringify(bundle).length / MB).toFixed(3)} MB`,
});
}
});
25 changes: 7 additions & 18 deletions contract/test/test-orca-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,23 @@ import { makeZoeKitForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { AmountMath, AssetKind, makeIssuerKit } from '@agoric/ertp';
// import { prepareOrchestrationTools } from '@agoric/orchestration'


// import { reincarnate } from '@agoric/swingset-liveslots/tools/setup-vat-data.js';

// /** @type {ReturnType<typeof reincarnate>} */
// let incarnation;


// export const getBaggage = () => {
// return incarnation.fakeVomKit.cm.provideBaggage();
// };



/** @typedef {typeof import('../src/orca.contract.js/index.js').start} AssetContractFn */

const myRequire = createRequire(import.meta.url);
const contractPath = myRequire.resolve(
`../src/orca.contract.js`,
);
const contractPath = myRequire.resolve(`../src/orca.contract.js`);

/** @type {import('ava').TestFn<Awaited<ReturnType<makeTestContext>>>} */
const test = anyTest;


/**
* Tests assume access to the zoe service and that contracts are bundled.
*
Expand All @@ -59,14 +52,11 @@ test('Install the contract', async t => {
t.is(typeof installation, 'object');
});

test('Start Orca contract and test joining', async t => {

test.skip('Start Orca contract and test joining', async t => {
const { zoe, bundle } = t.context;
const installation = E(zoe).install(bundle);

const terms = {

};
const terms = {};

// let privateArgs = {
// orchestration: await orchestration,
Expand All @@ -88,12 +78,11 @@ test('Start Orca contract and test joining', async t => {
// } = t.context;

// const { instance } = await E(zoe).startInstance(
// installation,
// {},
// installation,
// {},
// terms,
// {

// }
// );

});
});

0 comments on commit 386fb5f

Please sign in to comment.