BasicToken.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const assertJump = require('./helpers/assertJump');
  2. var BasicTokenMock = artifacts.require("./helpers/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. let transfer = 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. try {
  20. let transfer = await token.transfer(accounts[1], 101);
  21. } catch(error) {
  22. return assertJump(error);
  23. }
  24. assert.fail('should have thrown before');
  25. });
  26. });