mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-27 14:56:07 +00:00
Reject when probability is 0 (#212)
* Reject when probability is 0 * Apply custom error
This commit is contained in:
parent
bfa5a78b4f
commit
604d4c87eb
@ -19,6 +19,7 @@ abstract contract Proofs is Periods {
|
||||
error Proofs_ProofNotMissing();
|
||||
error Proofs_ProofNotRequired();
|
||||
error Proofs_ProofAlreadyMarkedMissing();
|
||||
error Proofs_InvalidProbability();
|
||||
|
||||
ProofConfig private _config;
|
||||
IGroth16Verifier private _verifier;
|
||||
@ -69,6 +70,9 @@ abstract contract Proofs is Periods {
|
||||
* and saves the required probability.
|
||||
*/
|
||||
function _startRequiringProofs(SlotId id, uint256 probability) internal {
|
||||
if (probability == 0) {
|
||||
revert Proofs_InvalidProbability();
|
||||
}
|
||||
_slotStarts[id] = block.timestamp;
|
||||
_probabilities[id] = probability;
|
||||
}
|
||||
|
@ -299,5 +299,12 @@ describe("Proofs", function () {
|
||||
await proofs.setSlotState(slotId, SlotState.Finished)
|
||||
expect(await proofs.isProofRequired(slotId)).to.be.false
|
||||
})
|
||||
|
||||
it("is rejected when probability is 0", async function () {
|
||||
const probability = 0
|
||||
await expect(
|
||||
proofs.startRequiringProofs(slotId, probability)
|
||||
).to.be.revertedWith("Proofs_InvalidProbability")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user