Unverified Commit f2112be4 by Hadrien Croubois Committed by GitHub

Add revert string to Counter decrement overflow (#2500)

parent c82895fb
......@@ -23,10 +23,16 @@ library Counters {
}
function increment(Counter storage counter) internal {
counter._value += 1;
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
counter._value = counter._value - 1;
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
}
......@@ -43,7 +43,7 @@ contract('Counters', function (accounts) {
it('reverts if the current value is 0', async function () {
await this.counter.decrement();
await expectRevert.unspecified(this.counter.decrement());
await expectRevert(this.counter.decrement(), 'Counter: decrement overflow');
});
});
context('after incremented to 3', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment