BasicToken.test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import assertRevert from '../helpers/assertRevert';
  2. var BasicTokenMock = artifacts.require('mocks/BasicTokenMock.sol');
  3. contract('BasicToken', function (accounts) {
  4. it('should return the correct totalSupply after construction', async function () {
  5. let token = await BasicTokenMock.new(accounts[0], 100);
  6. let totalSupply = await token.totalSupply();
  7. assert.equal(totalSupply, 100);
  8. });
  9. it('should return correct balances after transfer', async function () {
  10. let token = await BasicTokenMock.new(accounts[0], 100);
  11. await token.transfer(accounts[1], 100);
  12. let firstAccountBalance = await token.balanceOf(accounts[0]);
  13. assert.equal(firstAccountBalance, 0);
  14. let secondAccountBalance = await token.balanceOf(accounts[1]);
  15. assert.equal(secondAccountBalance, 100);
  16. });
  17. it('should throw an error when trying to transfer more than balance', async function () {
  18. let token = await BasicTokenMock.new(accounts[0], 100);
  19. await assertRevert(token.transfer(accounts[1], 101));
  20. });
  21. it('should throw an error when trying to transfer to 0x0', async function () {
  22. let token = await BasicTokenMock.new(accounts[0], 100);
  23. await assertRevert(token.transfer(0x0, 100));
  24. });
  25. });