Remove ERC20._burnFrom (#2119)
* Remove ERC20._burnFrom * Add changelog entry
This commit is contained in:
@ -262,80 +262,6 @@ describe('ERC20', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('_burnFrom', function () {
|
||||
const allowance = new BN(70);
|
||||
|
||||
const spender = anotherAccount;
|
||||
|
||||
beforeEach('approving', async function () {
|
||||
await this.token.approve(spender, allowance, { from: initialHolder });
|
||||
});
|
||||
|
||||
it('rejects a null account', async function () {
|
||||
await expectRevert(this.token.burnFrom(ZERO_ADDRESS, new BN(1)),
|
||||
'ERC20: burn from the zero address'
|
||||
);
|
||||
});
|
||||
|
||||
describe('for a non zero account', function () {
|
||||
it('rejects burning more than allowance', async function () {
|
||||
await expectRevert(this.token.burnFrom(initialHolder, allowance.addn(1)),
|
||||
'ERC20: burn amount exceeds allowance'
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects burning more than balance', async function () {
|
||||
await expectRevert(this.token.burnFrom(initialHolder, initialSupply.addn(1)),
|
||||
'ERC20: burn amount exceeds balance'
|
||||
);
|
||||
});
|
||||
|
||||
const describeBurnFrom = function (description, amount) {
|
||||
describe(description, function () {
|
||||
beforeEach('burning', async function () {
|
||||
const { logs } = await this.token.burnFrom(initialHolder, amount, { from: spender });
|
||||
this.logs = logs;
|
||||
});
|
||||
|
||||
it('decrements totalSupply', async function () {
|
||||
const expectedSupply = initialSupply.sub(amount);
|
||||
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
|
||||
});
|
||||
|
||||
it('decrements initialHolder balance', async function () {
|
||||
const expectedBalance = initialSupply.sub(amount);
|
||||
expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(expectedBalance);
|
||||
});
|
||||
|
||||
it('decrements spender allowance', async function () {
|
||||
const expectedAllowance = allowance.sub(amount);
|
||||
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(expectedAllowance);
|
||||
});
|
||||
|
||||
it('emits a Transfer event', async function () {
|
||||
const event = expectEvent.inLogs(this.logs, 'Transfer', {
|
||||
from: initialHolder,
|
||||
to: ZERO_ADDRESS,
|
||||
});
|
||||
|
||||
expect(event.args.value).to.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('emits an Approval event', async function () {
|
||||
expectEvent.inLogs(this.logs, 'Approval', {
|
||||
owner: initialHolder,
|
||||
spender: spender,
|
||||
value: await this.token.allowance(initialHolder, spender),
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describeBurnFrom('for entire allowance', allowance);
|
||||
describeBurnFrom('for less amount than allowance', allowance.subn(1));
|
||||
});
|
||||
});
|
||||
|
||||
describe('_transfer', function () {
|
||||
shouldBehaveLikeERC20Transfer('ERC20', initialHolder, recipient, initialSupply, function (from, to, amount) {
|
||||
return this.token.transferInternal(from, to, amount);
|
||||
|
||||
Reference in New Issue
Block a user