ERC20Capped.behavior.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. const shouldFail = require('../../../helpers/shouldFail');
  2. require('../../../helpers/setup');
  3. function shouldBehaveLikeERC20Capped (minter, [anyone], cap) {
  4. describe('capped token', function () {
  5. const from = minter;
  6. it('should start with the correct cap', async function () {
  7. (await this.token.cap()).should.be.bignumber.equal(cap);
  8. });
  9. it('should mint when amount is less than cap', async function () {
  10. await this.token.mint(anyone, cap.sub(1), { from });
  11. (await this.token.totalSupply()).should.be.bignumber.equal(cap.sub(1));
  12. });
  13. it('should fail to mint if the ammount exceeds the cap', async function () {
  14. await this.token.mint(anyone, cap.sub(1), { from });
  15. await shouldFail.reverting(this.token.mint(anyone, 100, { from }));
  16. });
  17. it('should fail to mint after cap is reached', async function () {
  18. await this.token.mint(anyone, cap, { from });
  19. await shouldFail.reverting(this.token.mint(anyone, 1, { from }));
  20. });
  21. });
  22. }
  23. module.exports = {
  24. shouldBehaveLikeERC20Capped,
  25. };