BasicToken.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. contract('BasicToken', function(accounts) {
  2. it("should return the correct totalSupply after construction", async function(done) {
  3. let token = await BasicTokenMock.new(accounts[0], 100);
  4. let totalSupply = await token.totalSupply();
  5. assert.equal(totalSupply, 100);
  6. done();
  7. })
  8. it("should return correct balances after transfer", async function(done){
  9. let token = await BasicTokenMock.new(accounts[0], 100);
  10. let transfer = await token.transfer(accounts[1], 100);
  11. let firstAccountBalance = await token.balanceOf(accounts[0]);
  12. assert.equal(firstAccountBalance, 0);
  13. let secondAccountBalance = await token.balanceOf(accounts[1]);
  14. assert.equal(secondAccountBalance, 100);
  15. done();
  16. });
  17. it("should throw an error when trying to transfer more than balance", async function(done) {
  18. let token = await BasicTokenMock.new(accounts[0], 100);
  19. try {
  20. let transfer = await token.transfer(accounts[1], 101);
  21. } catch(error) {
  22. if (error.message.search('invalid JUMP') === -1) throw error
  23. assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP error must be returned');
  24. done();
  25. }
  26. });
  27. });