Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into eq-equal
  • Loading branch information
nventuro authored Aug 23, 2018
commit 13204db81508b5c7025d6dbace7127154926adbf
73 changes: 49 additions & 24 deletions test/token/ERC20/BurnableToken.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,28 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
shouldBurn(100);
});

it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});

it('emits a transfer event', async function () {
const event = expectEvent.inLogs(this.logs, 'Transfer');
event.args.from.should.equal(owner);
event.args.to.should.equal(ZERO_ADDRESS);
event.args.value.should.be.bignumber.equal(amount);
});
function shouldBurn (amount) {
beforeEach(async function () {
({ logs: this.logs } = await this.token.burn(amount, { from: owner }));
});

it('burns the requested amount', async function () {
(await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance - amount);
});

it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});

it('emits a transfer event', async function () {
const event = expectEvent.inLogs(this.logs, 'Transfer');
event.args.from.should.equal(owner);
event.args.to.should.equal(ZERO_ADDRESS);
event.args.value.should.be.bignumber.equal(amount);
});
}
});

describe('when the given amount is greater than the balance of the sender', function () {
Expand All @@ -55,18 +65,33 @@ function shouldBehaveLikeBurnableToken (owner, initialBalance, [burner]) {
function shouldBurnFrom (amount) {
const originalAllowance = amount * 3;

it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});

it('emits a transfer event', async function () {
const event = expectEvent.inLogs(this.logs, 'Transfer');
event.args.from.should.equal(owner);
event.args.to.should.equal(ZERO_ADDRESS);
event.args.value.should.be.bignumber.equal(amount);
});
beforeEach(async function () {
await this.token.approve(burner, originalAllowance, { from: owner });
const { logs } = await this.token.burnFrom(owner, amount, { from: burner });
this.logs = logs;
});

it('burns the requested amount', async function () {
(await this.token.balanceOf(owner)).should.be.bignumber.equal(initialBalance - amount);
});

it('decrements allowance', async function () {
(await this.token.allowance(owner, burner)).should.be.bignumber.equal(originalAllowance - amount);
});

it('emits a burn event', async function () {
const event = expectEvent.inLogs(this.logs, 'Burn');
event.args.burner.should.equal(owner);
event.args.value.should.be.bignumber.equal(amount);
});

it('emits a transfer event', async function () {
const event = expectEvent.inLogs(this.logs, 'Transfer');
event.args.from.should.equal(owner);
event.args.to.should.equal(ZERO_ADDRESS);
event.args.value.should.be.bignumber.equal(amount);
});
}
});

describe('when the given amount is greater than the balance of the sender', function () {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.