diff --git a/modules/allowances/contracts/AllowanceModule.sol b/modules/allowances/contracts/AllowanceModule.sol index 8a3525a5..92564d9f 100644 --- a/modules/allowances/contracts/AllowanceModule.sol +++ b/modules/allowances/contracts/AllowanceModule.sol @@ -89,7 +89,7 @@ contract AllowanceModule is SignatureDecoder { // solium-disable-next-line security/no-block-members uint32 currentMin = uint32(block.timestamp / 60); if (resetBaseMin > 0) { - require(resetBaseMin <= currentMin, "resetBaseMin <= currentMin"); + require(resetBaseMin <= currentMin && resetTimeMin > 0, "resetBaseMin <= currentMin && resetTimeMin > 0"); allowance.lastResetMin = currentMin - ((currentMin - resetBaseMin) % resetTimeMin); } else if (allowance.lastResetMin == 0) { allowance.lastResetMin = currentMin; diff --git a/modules/allowances/test/allowanceRecurring.spec.ts b/modules/allowances/test/allowanceRecurring.spec.ts index 3006766d..63a0be1e 100644 --- a/modules/allowances/test/allowanceRecurring.spec.ts +++ b/modules/allowances/test/allowanceRecurring.spec.ts @@ -133,4 +133,24 @@ describe('AllowanceModule allowanceRecurring', () => { expect(expectedLastReset).to.be.equal(resetLast) expect(4).to.equal(nonce) }) + + it('Reverts when trying to set up a recurring allowance with reset period of 0', async () => { + const { safe, allowanceModule, token, owner, alice } = await loadFixture(setup) + const tokenAddress = await token.getAddress() + + // add alice as delegate + await execSafeTransaction(safe, await allowanceModule.addDelegate.populateTransaction(alice.address), owner) + + // create an allowance for alice + const configResetPeriod = 0 + const configResetBase = nowInMinutes() + + await expect( + execSafeTransaction( + safe, + await allowanceModule.setAllowance.populateTransaction(alice.address, tokenAddress, 100, configResetPeriod, configResetBase), + owner, + ), + ).to.be.reverted + }) })