diff --git a/contracts/Proofs.sol b/contracts/Proofs.sol index aa9c3b2..a169506 100644 --- a/contracts/Proofs.sol +++ b/contracts/Proofs.sol @@ -71,7 +71,7 @@ abstract contract Proofs is Periods { pointer = _getPointer(id, period); bytes32 challenge = _getChallenge(pointer); uint256 probability = (_probabilities[id] * (256 - _config.downtime)) / 256; - isRequired = uint256(challenge) % probability == 0; + isRequired = probability == 0 || uint256(challenge) % probability == 0; } function _isProofRequired( diff --git a/test/Proofs.test.js b/test/Proofs.test.js index c1525f9..561ee9b 100644 --- a/test/Proofs.test.js +++ b/test/Proofs.test.js @@ -41,6 +41,7 @@ describe("Proofs", function () { it("requires proofs with an agreed upon probability", async function () { await proofs.startRequiringProofs(slotId, probability) + await advanceTime(period) let amount = 0 for (let i = 0; i < 100; i++) { if (await proofs.isProofRequired(slotId)) { @@ -52,6 +53,15 @@ describe("Proofs", function () { expect(amount).to.be.closeTo(expected, expected / 2) }) + it("supports probability 1 (proofs are always required)", async function () { + await proofs.startRequiringProofs(slotId, 1) + await advanceTime(period) + while ((await proofs.getPointer(slotId)) < downtime) { + await mine() + } + expect(await proofs.isProofRequired(slotId)).to.be.true + }) + it("requires no proofs in the start period", async function () { const startPeriod = Math.floor((await currentTime()) / period) const probability = 1