From 4fe837704b7a2eb6167e5f3a1a720eaf8fd02451 Mon Sep 17 00:00:00 2001 From: SylTi Date: Wed, 2 Aug 2017 01:44:18 +0200 Subject: [PATCH] Add Transfer event when token is minted to be fully ERC20 compliant & tests --- contracts/token/MintableToken.sol | 1 + test/MintableToken.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/token/MintableToken.sol b/contracts/token/MintableToken.sol index e2854d56a..92f591012 100644 --- a/contracts/token/MintableToken.sol +++ b/contracts/token/MintableToken.sol @@ -35,6 +35,7 @@ contract MintableToken is StandardToken, Ownable { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); + Transfer(0x0, _to, _amount); return true; } diff --git a/test/MintableToken.js b/test/MintableToken.js index 4f574d51d..a3ae8968e 100644 --- a/test/MintableToken.js +++ b/test/MintableToken.js @@ -23,8 +23,13 @@ contract('Mintable', function(accounts) { }); it('should mint a given amount of tokens to a given address', async function() { - await token.mint(accounts[0], 100); - + const result = await token.mint(accounts[0], 100); + assert.equal(result.logs[0].event, 'Mint'); + assert.equal(result.logs[0].args.to.valueOf(), accounts[0]); + assert.equal(result.logs[0].args.amount.valueOf(), 100); + assert.equal(result.logs[1].event, 'Transfer'); + assert.equal(result.logs[1].args.from.valueOf(), 0x0); + let balance0 = await token.balanceOf(accounts[0]); assert(balance0, 100);