Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Apr 5, 2024
1 parent daf8edb commit 91190d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/contracts/Tally.sol
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher {
uint256 _totalSpentSalt,
uint256 _resultCommitment,
uint256 _perVOSpentVoiceCreditsHash
) private view returns (bool isValid) {
) internal view returns (bool isValid) {
uint256[3] memory tally;
tally[0] = _resultCommitment;
tally[1] = hashLeftRight(_totalSpent, _totalSpentSalt);
Expand All @@ -288,7 +288,7 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher {
uint256 _totalSpent,
uint256 _totalSpentSalt,
uint256 _resultCommitment
) private view returns (bool isValid) {
) internal view returns (bool isValid) {
uint256[2] memory tally;
tally[0] = _resultCommitment;
tally[1] = hashLeftRight(_totalSpent, _totalSpentSalt);
Expand Down
7 changes: 7 additions & 0 deletions contracts/tests/TallyNonQv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ describe("TallyVotesNonQv", () => {
expect(isTallied).to.eq(true);
});

it("should throw error if try to call verifyPerVOSpentVoiceCredits for non-qv", async () => {
await expect(tallyContract.verifyPerVOSpentVoiceCredits(0, 0, [], 0, 0, 0, 0)).to.be.revertedWithCustomError(
tallyContract,
"NotSupported",
);
});

it("tallyVotes() should revert when votes have already been tallied", async () => {
await expect(
tallyContract.tallyVotes(tallyGeneratedInputs.newTallyCommitment, [0, 0, 0, 0, 0, 0, 0, 0]),
Expand Down

0 comments on commit 91190d6

Please sign in to comment.