approve failing test

This commit is contained in:
Aniket-Engg
2018-10-11 16:07:39 +05:30
parent 9bb567055f
commit b40c76d0b1
2 changed files with 11 additions and 3 deletions

View File

@ -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);
}

View File

@ -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();
});