Skip to content

Commit

Permalink
fix: harden where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Dec 28, 2021
1 parent 005ccaf commit c6197bc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
42 changes: 24 additions & 18 deletions packages/governance/test/unitTests/test-shareHolders.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,21 @@ const attest = (addr, amountLiened, expiration) => {
* @param {Timestamp} deadline
*/
const makeDefaultBallotSpec = (issue, positions, timer, deadline) => {
const questionSpec = looksLikeQuestionSpec({
method: ChoiceMethod.UNRANKED,
issue,
positions,
electionType: ElectionType.ELECTION,
maxChoices: 1,
closingRule: {
timer,
deadline,
},
quorumRule: QuorumRule.NO_QUORUM,
tieOutcome: positions[1],
});
const questionSpec = looksLikeQuestionSpec(
harden({
method: ChoiceMethod.UNRANKED,
issue,
positions,
electionType: ElectionType.ELECTION,
maxChoices: 1,
closingRule: {
timer,
deadline,
},
quorumRule: QuorumRule.NO_QUORUM,
tieOutcome: positions[1],
}),
);

return questionSpec;
};
Expand All @@ -94,9 +96,13 @@ const offerToVoteSeat = (attestationMint, publicElectorate, attestation) => {
give: { Attestation: attestation },
want: {},
});
return E(zoe).offer(E(publicElectorate).makeVoterInvitation(), proposal, {
Attestation: attestation1,
});
return E(zoe).offer(
E(publicElectorate).makeVoterInvitation(),
proposal,
harden({
Attestation: attestation1,
}),
);
};

/**
Expand All @@ -114,10 +120,10 @@ const voterFacet = (mint, publicFacet, attestAmmount) => {
*/
const addDeposeQuestion = async (timer, creatorFacet) => {
const depose = harden({ text: 'Replace the CEO?' });
const deposePositions = [
const deposePositions = harden([
harden({ text: 'Yes, replace' }),
harden({ text: 'no change' }),
];
]);
const deposeSpec = makeDefaultBallotSpec(depose, deposePositions, timer, 2n);
const { publicFacet: deposeCounter, questionHandle } = await E(
creatorFacet,
Expand Down
9 changes: 5 additions & 4 deletions packages/zoe/src/cleanProposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ export const assertKeywordName = keyword => {
};

/**
* @param {{[name: string]: any}} keywordRecord
* @param {{[name: string]: any}} uncleanKeywordRecord
* @returns {string[]}
*/
export const cleanKeywords = keywordRecord => {
assertRecord(keywordRecord, 'keywordRecord');
const keywords = ownKeys(keywordRecord);
export const cleanKeywords = uncleanKeywordRecord => {
harden(uncleanKeywordRecord);
assertRecord(uncleanKeywordRecord, 'keywordRecord');
const keywords = ownKeys(uncleanKeywordRecord);

// Assert all names are ascii identifiers starting with
// an upper case letter.
Expand Down

0 comments on commit c6197bc

Please sign in to comment.