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.
46 lines
1.5 KiB
46 lines
1.5 KiB
7 years ago
|
import assertRevert from '../../helpers/assertRevert';
|
||
7 years ago
|
const BurnableTokenMock = artifacts.require('BurnableTokenMock');
|
||
8 years ago
|
|
||
7 years ago
|
contract('BurnableToken', function ([owner]) {
|
||
|
beforeEach(async function () {
|
||
|
this.token = await BurnableTokenMock.new(owner, 1000);
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
describe('burn', function () {
|
||
|
const from = owner;
|
||
8 years ago
|
|
||
7 years ago
|
describe('when the given amount is not greater than balance of the sender', function () {
|
||
|
const amount = 100;
|
||
8 years ago
|
|
||
7 years ago
|
it('burns the requested amount', async function () {
|
||
|
await this.token.burn(amount, { from });
|
||
8 years ago
|
|
||
7 years ago
|
const balance = await this.token.balanceOf(from);
|
||
|
assert.equal(balance, 900);
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
it('emits a burn event', async function () {
|
||
|
const { logs } = await this.token.burn(amount, { from });
|
||
7 years ago
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||
|
assert.equal(logs.length, 2);
|
||
7 years ago
|
assert.equal(logs[0].event, 'Burn');
|
||
|
assert.equal(logs[0].args.burner, owner);
|
||
|
assert.equal(logs[0].args.value, amount);
|
||
7 years ago
|
|
||
|
assert.equal(logs[1].event, 'Transfer');
|
||
|
assert.equal(logs[1].args.from, owner);
|
||
|
assert.equal(logs[1].args.to, ZERO_ADDRESS);
|
||
|
assert.equal(logs[1].args.value, amount);
|
||
7 years ago
|
});
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
describe('when the given amount is greater than the balance of the sender', function () {
|
||
|
const amount = 1001;
|
||
8 years ago
|
|
||
7 years ago
|
it('reverts', async function () {
|
||
|
await assertRevert(this.token.burn(amount, { from }));
|
||
|
});
|
||
|
});
|
||
7 years ago
|
});
|
||
|
});
|