CappedToken.test.js 993 B

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