mirror of openzeppelin-contracts
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.
openzeppelin-contracts/test/token/ERC20/BurnableToken.test.js

46 lines
1.5 KiB

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