CappedToken.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. import expectThrow from './helpers/expectThrow';
  3. import ether from './helpers/ether';
  4. var CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol');
  5. const BigNumber = web3.BigNumber
  6. contract('Capped', function(accounts) {
  7. const cap = ether(1000);
  8. let token;
  9. beforeEach(async function() {
  10. token = await CappedToken.new(cap);
  11. })
  12. it('should start with the correct cap', async function() {
  13. let _cap = await token.cap();
  14. assert(cap.eq(_cap));
  15. })
  16. it('should mint when amount is less than cap', async function() {
  17. const result = await token.mint(accounts[0], 100);
  18. assert.equal(result.logs[0].event, 'Mint');
  19. })
  20. it('should fail to mint if the ammount exceeds the cap', async function() {
  21. await token.mint(accounts[0], cap.sub(1));
  22. await expectThrow(token.mint(accounts[0], 100));
  23. })
  24. it('should fail to mint after cap is reached', async function() {
  25. await token.mint(accounts[0], cap);
  26. await expectThrow(token.mint(accounts[0], 1));
  27. })
  28. });