MintableToken.test.js 1.4 KB

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