Skip to content

Commit

Permalink
Merge pull request #189 from pooltogether/pool-1705-drawcalculatormat…
Browse files Browse the repository at this point in the history
…chcardinality-needs-to

added matchCardinality gt 0 check
  • Loading branch information
aodhgan committed Oct 6, 2021
2 parents 8906897 + e5ab5b7 commit 7a7e22a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contracts/PrizeDistributionHistory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ contract PrizeDistributionHistory is IPrizeDistributionHistory, Manageable {
uint32 _drawId,
DrawLib.PrizeDistribution calldata _prizeDistribution
) internal returns (bool) {

require(_drawId > 0, "DrawCalc/draw-id-gt-0");

require(_prizeDistribution.matchCardinality > 0, "DrawCalc/matchCardinality-gt-0");
require(
_prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality,
"DrawCalc/bitRangeSize-too-large"
Expand Down
8 changes: 8 additions & 0 deletions test/PrizeDistributionHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ describe('PrizeDistributionHistory', () => {
).to.be.revertedWith('DrawCalc/bitRangeSize-gt-0');
});

it('cannot set matchCardinality = 0', async () => {
prizeDistribution.matchCardinality = BigNumber.from(0);

await expect(
prizeDistributionHistory.pushPrizeDistribution(1, prizeDistribution),
).to.be.revertedWith('DrawCalc/matchCardinality-gt-0');
});

it('cannot set maxPicksPerUser = 0', async () => {
prizeDistribution.maxPicksPerUser = BigNumber.from(0);

Expand Down

0 comments on commit 7a7e22a

Please sign in to comment.