MintableToken.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. import expectThrow from './helpers/expectThrow';
  3. var MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol');
  4. contract('Mintable', function(accounts) {
  5. let token;
  6. beforeEach(async function() {
  7. token = await MintableToken.new();
  8. });
  9. it('should start with a totalSupply of 0', async function() {
  10. let totalSupply = await token.totalSupply();
  11. assert.equal(totalSupply, 0);
  12. });
  13. it('should return mintingFinished false after construction', async function() {
  14. let mintingFinished = await token.mintingFinished();
  15. assert.equal(mintingFinished, false);
  16. });
  17. it('should mint a given amount of tokens to a given address', async function() {
  18. const result = await token.mint(accounts[0], 100);
  19. assert.equal(result.logs[0].event, 'Mint');
  20. assert.equal(result.logs[0].args.to.valueOf(), accounts[0]);
  21. assert.equal(result.logs[0].args.amount.valueOf(), 100);
  22. assert.equal(result.logs[1].event, 'Transfer');
  23. assert.equal(result.logs[1].args.from.valueOf(), 0x0);
  24. let balance0 = await token.balanceOf(accounts[0]);
  25. assert(balance0, 100);
  26. let totalSupply = await token.totalSupply();
  27. assert(totalSupply, 100);
  28. })
  29. it('should fail to mint after call to finishMinting', async function () {
  30. await token.finishMinting();
  31. assert.equal(await token.mintingFinished(), true);
  32. await expectThrow(token.mint(accounts[0], 100));
  33. })
  34. });