Skip to content

Commit

Permalink
fixup! test(test-committee-vote): vote with committee (WIP?)
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Mar 12, 2024
1 parent c08a8c8 commit 3116ff7
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions contract/test/test-vote-by-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import {
installSwapContract,
permit,
startContract,
startSwaparooCharter,
startSwaparooCommittee,
} from '../src/swaparoo.proposal.js';
import { makeBundleCacheContext } from '../tools/bundle-tools.js';
import { NonNullish } from '../src/objectTools.js';
import { installCommitteeContract } from './lib-gov-test/puppet-gov.js';
import {
installCommitteeContract,

Check failure on line 19 in contract/test/test-vote-by-committee.js

View workflow job for this annotation

GitHub Actions / all

'installCommitteeContract' is defined but never used. Allowed unused vars must match /^_/u
assets as govAssets,
} from './lib-gov-test/puppet-gov.js';

/** @typedef {import('./wallet-tools.js').MockWallet} MockWallet */

Expand All @@ -26,34 +30,36 @@ const nodeRequire = createRequire(import.meta.url);
const contractName = 'swaparoo';
export const assets = {
[contractName]: nodeRequire.resolve(`../src/${contractName}.contract.js`),
contractGovernor: nodeRequire.resolve(
'@agoric/governance/src/contractGovernor.js',
),
binaryVoteCounter: nodeRequire.resolve(
'@agoric/governance/src/binaryVoteCounter.js',
),
};

const makeTestContext = async t => {
const bc = await makeBundleCacheContext(t);
t.log('bootstrap');
const { powers, vatAdminState } = await mockBootstrapPowers(t.log);

// TODO: push down?
const { zoe } = powers.consume;
for await (const [name, asset] of Object.entries({
contractGovernor: govAssets.contractGovernor,
binaryVoteCounter: govAssets.binaryVoteCounter,
committee: govAssets.committee,
econCommitteeCharter: govAssets.committeeCharter,
})) {
t.log('installation:', name);
powers.installation.produce[name].resolve(
E(zoe).install(await bc.bundleCache.load(asset)),
);
}

return { ...bc, powers, vatAdminState };
};

test.before(async t => (t.context = await makeTestContext(t)));

test.serial('start committee', async t => {
const { bundleCache, powers } = t.context;
const { zoe } = powers.consume;
await installCommitteeContract(zoe, powers.installation.produce, bundleCache);
powers.installation.produce.contractGovernor.resolve(
E(zoe).install(await bundleCache.load(assets.contractGovernor)),
);
powers.installation.produce.binaryVoteCounter.resolve(
E(zoe).install(await bundleCache.load(assets.binaryVoteCounter)),
);
test.serial('start committee, charter', async t => {
const { powers } = t.context;

const permittedPowers = extractPowers(permit, powers);
const config = {
options: {
swaparooCommittee: {
Expand All @@ -63,7 +69,11 @@ test.serial('start committee', async t => {
},
},
};
const facets = await startSwaparooCommittee(powers, config);
const [facets] = await Promise.all([
// TODO: move to main export of swaproo.proposal
startSwaparooCommittee(permittedPowers, config),
startSwaparooCharter(permittedPowers),
]);
t.is(typeof facets.instance, 'object');
});

Expand Down

0 comments on commit 3116ff7

Please sign in to comment.