SafeERC20.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import EVMThrow from './helpers/EVMThrow';
  2. require('chai')
  3. .use(require('chai-as-promised'))
  4. .should();
  5. const SafeERC20Helper = artifacts.require('./helpers/SafeERC20Helper.sol');
  6. contract('SafeERC20', function () {
  7. beforeEach(async function () {
  8. this.helper = await SafeERC20Helper.new();
  9. });
  10. it('should throw on failed transfer', async function () {
  11. await this.helper.doFailingTransfer().should.be.rejectedWith(EVMThrow);
  12. });
  13. it('should throw on failed transferFrom', async function () {
  14. await this.helper.doFailingTransferFrom().should.be.rejectedWith(EVMThrow);
  15. });
  16. it('should throw on failed approve', async function () {
  17. await this.helper.doFailingApprove().should.be.rejectedWith(EVMThrow);
  18. });
  19. it('should not throw on succeeding transfer', async function () {
  20. await this.helper.doSucceedingTransfer().should.be.fulfilled;
  21. });
  22. it('should not throw on succeeding transferFrom', async function () {
  23. await this.helper.doSucceedingTransferFrom().should.be.fulfilled;
  24. });
  25. it('should not throw on succeeding approve', async function () {
  26. await this.helper.doSucceedingApprove().should.be.fulfilled;
  27. });
  28. });