From 289fd87ef847ce43049d5674f777a6ad15340df8 Mon Sep 17 00:00:00 2001 From: Rudy Godoy Date: Sun, 20 Aug 2017 23:19:50 -0500 Subject: [PATCH] Tests increase and decrease allowance for spender - Spender starts with 0 tokens allowed to spend - Spender is granted 50, then decreased it's allowance by 10 Refs PR #224 --- test/StandardToken.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/StandardToken.js b/test/StandardToken.js index 3a96be81b..96a51afe5 100644 --- a/test/StandardToken.js +++ b/test/StandardToken.js @@ -70,4 +70,22 @@ contract('StandardToken', function(accounts) { } }); + describe('validating allowance updates to spender', function() { + let preApproved; + + it('should start with zero', async function() { + preApproved = await token.allowance(accounts[0], accounts[1]); + assert.equal(preApproved, 0); + }) + + it('should increase by 50 then decrease by 10', async function() { + await token.increaseApproval(accounts[1], 50); + let postIncrease = await token.allowance(accounts[0], accounts[1]); + preApproved.plus(50).should.be.bignumber.equal(postIncrease); + await token.decreaseApproval(accounts[1], 10); + let postDecrease = await token.allowance(accounts[0], accounts[1]); + postIncrease.minus(10).should.be.bignumber.equal(postDecrease); + }) + }); + });