CappedToken.test.js 1.0 KB

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