add safe ERC20 helpers

This commit is contained in:
Francisco Giordano
2017-08-28 17:30:59 -03:00
parent af6fdae3dd
commit c7636bdc4c
3 changed files with 97 additions and 0 deletions

27
test/SafeERC20.js Normal file
View File

@ -0,0 +1,27 @@
import EVMThrow from './helpers/EVMThrow';
require('chai')
.use(require('chai-as-promised'))
.should();
const SafeERC20Helper = artifacts.require('./helpers/SafeERC20Helper.sol');
contract('SafeERC20', function () {
beforeEach(async function () {
this.helper = await SafeERC20Helper.new();
});
it('should throw on failed transfer', async function () {
await this.helper.doFailingTransfer().should.be.rejectedWith(EVMThrow);
});
it('should throw on failed transferFrom', async function () {
await this.helper.doFailingTransferFrom().should.be.rejectedWith(EVMThrow);
});
it('should throw on failed approve', async function () {
await this.helper.doFailingApprove().should.be.rejectedWith(EVMThrow);
});
});