approve failing test
This commit is contained in:
@ -64,9 +64,9 @@ contract ERC20SucceedingMock {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function allowance(address, address) public view returns (uint256) {
|
||||
return _allowance;
|
||||
}
|
||||
function allowance(address, address) public view returns (uint256) {
|
||||
return 10; //non-zero allowance
|
||||
}
|
||||
}
|
||||
|
||||
contract SafeERC20Helper {
|
||||
@ -140,6 +140,10 @@ contract SafeERC20Helper {
|
||||
_succeeding.safeApprove(address(0), 0);
|
||||
}
|
||||
|
||||
function doFailingApproveByValue() public {
|
||||
_succeeding.safeApprove(address(0), 10);
|
||||
}
|
||||
|
||||
function doSucceedingIncreaseAllowance() public {
|
||||
_succeeding.safeIncreaseAllowance(address(0), 0);
|
||||
}
|
||||
|
||||
@ -99,6 +99,10 @@ contract('SafeERC20', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw while approving with non-zero existing allowance', async function () {
|
||||
await shouldFail.reverting(this.helper.doFailingApproveByValue());
|
||||
});
|
||||
|
||||
it('should not throw on succeeding increaseAllowance', async function () {
|
||||
await this.helper.doSucceedingIncreaseAllowance();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user