Commit cf583309 by lsaether

added tests for BurnableToken

parent b414545b
This source diff could not be displayed because it is too large. You can view the blob instead.
'use strict'
const EVMThrow = require('./helpers/EVMThrow.js')
const BurnableTokenMock = artifacts.require("./helpers/BurnableTokenMock.sol")
const BigNumber = web3.BigNumber
require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should()
const expect = require('chai').expect
contract('BurnableToken', function (accounts) {
let token
let expectedTokenSupply = new BigNumber(999)
beforeEach(async function () {
token = await BurnableTokenMock.new(accounts[0], 1000)
})
it('owner should be able to burn tokens', async function () {
const { logs } = await token.burn(1, { from: accounts[0] })
const balance = await token.balanceOf(accounts[0])
balance.should.be.bignumber.equal(expectedTokenSupply)
const totalSupply = await token.totalSupply()
totalSupply.should.be.bignumber.equal(expectedTokenSupply)
const event = logs.find(e => e.event === 'Burn')
expect(event).to.exist
})
it('cannot burn more tokens than your balance', async function () {
await token.burn(2000, { from: accounts[0] })
.should.be.rejectedWith(EVMThrow)
})
})
\ No newline at end of file
pragma solidity ^0.4.13;
import '../../contracts/token/BurnableToken.sol';
contract BurnableTokenMock is BurnableToken {
function BurnableTokenMock(address initialAccount, uint initialBalance) {
balances[initialAccount] = initialBalance;
totalSupply = initialBalance;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment