CappedToken.behaviour.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. const { expectThrow } = require('../../helpers/expectThrow');
  2. function shouldBehaveLikeCappedToken (minter, [anyone], cap) {
  3. describe('capped token', function () {
  4. const from = minter;
  5. it('should start with the correct cap', async function () {
  6. const _cap = await this.token.cap();
  7. assert(cap.eq(_cap));
  8. });
  9. it('should mint when amount is less than cap', async function () {
  10. const result = await this.token.mint(anyone, cap.sub(1), { from });
  11. assert.equal(result.logs[0].event, 'Mint');
  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 expectThrow(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 expectThrow(this.token.mint(anyone, 1, { from }));
  20. });
  21. });
  22. }
  23. module.exports = {
  24. shouldBehaveLikeCappedToken,
  25. };