You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
8 years ago
|
|
||
7 years ago
|
const EVMRevert = require('../helpers/EVMRevert.js');
|
||
7 years ago
|
const BurnableTokenMock = artifacts.require('mocks/BurnableTokenMock.sol');
|
||
7 years ago
|
const BigNumber = web3.BigNumber;
|
||
8 years ago
|
|
||
|
require('chai')
|
||
|
.use(require('chai-as-promised'))
|
||
|
.use(require('chai-bignumber')(BigNumber))
|
||
7 years ago
|
.should();
|
||
8 years ago
|
|
||
7 years ago
|
const expect = require('chai').expect;
|
||
8 years ago
|
|
||
|
contract('BurnableToken', function (accounts) {
|
||
7 years ago
|
let token;
|
||
|
let expectedTokenSupply = new BigNumber(999);
|
||
8 years ago
|
|
||
7 years ago
|
beforeEach(async function () {
|
||
|
token = await BurnableTokenMock.new(accounts[0], 1000);
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
it('owner should be able to burn tokens', async function () {
|
||
|
const { logs } = await token.burn(1, { from: accounts[0] });
|
||
8 years ago
|
|
||
7 years ago
|
const balance = await token.balanceOf(accounts[0]);
|
||
|
balance.should.be.bignumber.equal(expectedTokenSupply);
|
||
8 years ago
|
|
||
7 years ago
|
const totalSupply = await token.totalSupply();
|
||
|
totalSupply.should.be.bignumber.equal(expectedTokenSupply);
|
||
8 years ago
|
|
||
7 years ago
|
const event = logs.find(e => e.event === 'Burn');
|
||
|
expect(event).to.exist;
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
it('cannot burn more tokens than your balance', async function () {
|
||
|
await token.burn(2000, { from: accounts[0] })
|
||
|
.should.be.rejectedWith(EVMRevert);
|
||
|
});
|
||
|
});
|