123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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 }));
- });
- });
- });
- });
|