Removing more asserts in favor of require (#834)
* Removed asserts and replaced them in favor of require * Adapted tests to work with requires
This commit is contained in:
committed by
Francisco Giordano
parent
7e44204d9b
commit
85f079ee89
@ -36,7 +36,6 @@ contract HasNoEther is Ownable {
|
||||
* @dev Transfer all Ether held by the contract to the owner.
|
||||
*/
|
||||
function reclaimEther() external onlyOwner {
|
||||
// solium-disable-next-line security/no-send
|
||||
assert(owner.send(address(this).balance));
|
||||
owner.transfer(this.balance);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ import "./ERC20.sol";
|
||||
*/
|
||||
library SafeERC20 {
|
||||
function safeTransfer(ERC20Basic token, address to, uint256 value) internal {
|
||||
assert(token.transfer(to, value));
|
||||
require(token.transfer(to, value));
|
||||
}
|
||||
|
||||
function safeTransferFrom(
|
||||
@ -23,10 +23,10 @@ library SafeERC20 {
|
||||
)
|
||||
internal
|
||||
{
|
||||
assert(token.transferFrom(from, to, value));
|
||||
require(token.transferFrom(from, to, value));
|
||||
}
|
||||
|
||||
function safeApprove(ERC20 token, address spender, uint256 value) internal {
|
||||
assert(token.approve(spender, value));
|
||||
require(token.approve(spender, value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import EVMThrow from '../../helpers/EVMThrow';
|
||||
import EVMRevert from '../../helpers/EVMRevert';
|
||||
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
@ -12,15 +12,15 @@ contract('SafeERC20', function () {
|
||||
});
|
||||
|
||||
it('should throw on failed transfer', async function () {
|
||||
await this.helper.doFailingTransfer().should.be.rejectedWith(EVMThrow);
|
||||
await this.helper.doFailingTransfer().should.be.rejectedWith(EVMRevert);
|
||||
});
|
||||
|
||||
it('should throw on failed transferFrom', async function () {
|
||||
await this.helper.doFailingTransferFrom().should.be.rejectedWith(EVMThrow);
|
||||
await this.helper.doFailingTransferFrom().should.be.rejectedWith(EVMRevert);
|
||||
});
|
||||
|
||||
it('should throw on failed approve', async function () {
|
||||
await this.helper.doFailingApprove().should.be.rejectedWith(EVMThrow);
|
||||
await this.helper.doFailingApprove().should.be.rejectedWith(EVMRevert);
|
||||
});
|
||||
|
||||
it('should not throw on succeeding transfer', async function () {
|
||||
|
||||
Reference in New Issue
Block a user