SafeERC20.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const { expectThrow } = require('../../helpers/expectThrow');
  2. const { EVMRevert } = require('../../helpers/EVMRevert');
  3. require('chai')
  4. .should();
  5. const SafeERC20Helper = artifacts.require('SafeERC20Helper');
  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 expectThrow(this.helper.doFailingTransfer(), EVMRevert);
  12. });
  13. it('should throw on failed transferFrom', async function () {
  14. await expectThrow(this.helper.doFailingTransferFrom(), EVMRevert);
  15. });
  16. it('should throw on failed approve', async function () {
  17. await expectThrow(this.helper.doFailingApprove(), EVMRevert);
  18. });
  19. it('should not throw on succeeding transfer', async function () {
  20. await this.helper.doSucceedingTransfer();
  21. });
  22. it('should not throw on succeeding transferFrom', async function () {
  23. await this.helper.doSucceedingTransferFrom();
  24. });
  25. it('should not throw on succeeding approve', async function () {
  26. await this.helper.doSucceedingApprove();
  27. });
  28. });