From 3837319141a52e7ad6fc92af9177b3cf61e57c0e Mon Sep 17 00:00:00 2001 From: Dan Phifer Date: Sat, 23 Sep 2017 17:06:14 +0800 Subject: [PATCH] Adding some additional tests --- test/StandardToken.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/StandardToken.js b/test/StandardToken.js index 7dd11a782db..f82907ce007 100644 --- a/test/StandardToken.js +++ b/test/StandardToken.js @@ -1,6 +1,7 @@ 'use strict'; const assertJump = require('./helpers/assertJump'); +const expectThrow = require('./helpers/expectThrow'); var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol'); contract('StandardToken', function(accounts) { @@ -70,6 +71,17 @@ contract('StandardToken', function(accounts) { } }); + it('should throw an error when trying to transferFrom more than _from has', async function() { + let balance0 = await token.balanceOf(accounts[0]); + await token.approve(accounts[1], 99); + try { + await token.transferFrom(accounts[0], accounts[2], balance0+1, {from: accounts[1]}); + assert.fail('should have thrown before'); + } catch (error) { + assertJump(error); + } + }); + describe('validating allowance updates to spender', function() { let preApproved; @@ -88,6 +100,13 @@ contract('StandardToken', function(accounts) { }) }); + it('should increase by 50 then set to 0 when decreasing by more than 50', async function() { + await token.approve(accounts[1], 50); + await token.decreaseApproval(accounts[1], 60); + let postDecrease = await token.allowance(accounts[0], accounts[1]); + postDecrease.should.be.bignumber.equal(0); +}); + it('should throw an error when trying to transfer to 0x0', async function() { let token = await StandardTokenMock.new(accounts[0], 100); try {