CappedToken.behavior.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const { expectThrow } = require('../../helpers/expectThrow');
  2. const BigNumber = web3.BigNumber;
  3. require('chai')
  4. .use(require('chai-bignumber')(BigNumber))
  5. .should();
  6. function shouldBehaveLikeCappedToken (minter, [anyone], cap) {
  7. describe('capped token', function () {
  8. const from = minter;
  9. it('should start with the correct cap', async function () {
  10. (await this.token.cap()).should.be.bignumber.equal(cap);
  11. });
  12. it('should mint when amount is less than cap', async function () {
  13. const result = await this.token.mint(anyone, cap.sub(1), { from });
  14. result.logs[0].event.should.equal('Mint');
  15. });
  16. it('should fail to mint if the ammount exceeds the cap', async function () {
  17. await this.token.mint(anyone, cap.sub(1), { from });
  18. await expectThrow(this.token.mint(anyone, 100, { from }));
  19. });
  20. it('should fail to mint after cap is reached', async function () {
  21. await this.token.mint(anyone, cap, { from });
  22. await expectThrow(this.token.mint(anyone, 1, { from }));
  23. });
  24. });
  25. }
  26. module.exports = {
  27. shouldBehaveLikeCappedToken,
  28. };