ERC20PresetFixedSupply.test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const { BN, constants, expectEvent } = require('@openzeppelin/test-helpers');
  2. const { ZERO_ADDRESS } = constants;
  3. const { expect } = require('chai');
  4. const ERC20PresetFixedSupply = artifacts.require('ERC20PresetFixedSupply');
  5. contract('ERC20PresetFixedSupply', function (accounts) {
  6. const [deployer, owner] = accounts;
  7. const name = 'PresetFixedSupply';
  8. const symbol = 'PFS';
  9. const initialSupply = new BN('50000');
  10. const amount = new BN('10000');
  11. before(async function () {
  12. this.token = await ERC20PresetFixedSupply.new(name, symbol, initialSupply, owner, { from: deployer });
  13. });
  14. it('deployer has the balance equal to initial supply', async function () {
  15. expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(initialSupply);
  16. });
  17. it('total supply is equal to initial supply', async function () {
  18. expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
  19. });
  20. describe('burning', function () {
  21. it('holders can burn their tokens', async function () {
  22. const remainingBalance = initialSupply.sub(amount);
  23. const receipt = await this.token.burn(amount, { from: owner });
  24. expectEvent(receipt, 'Transfer', { from: owner, to: ZERO_ADDRESS, value: amount });
  25. expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(remainingBalance);
  26. });
  27. it('decrements totalSupply', async function () {
  28. const expectedSupply = initialSupply.sub(amount);
  29. expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
  30. });
  31. });
  32. });