|
|
|
const { assertRevert } = require('../../helpers/assertRevert');
|
|
|
|
const expectEvent = require('../../helpers/expectEvent');
|
|
|
|
|
|
|
|
const ERC20Mock = artifacts.require('ERC20Mock');
|
|
|
|
|
|
|
|
const BigNumber = web3.BigNumber;
|
|
|
|
|
|
|
|
require('chai')
|
|
|
|
.use(require('chai-bignumber')(BigNumber))
|
|
|
|
.should();
|
|
|
|
|
Rename ERC interfaces to I prefix (#1252)
* rename ERC20 to IERC20
* move ERC20.sol to IERC20.sol
* rename StandardToken to ERC20
* rename StandardTokenMock to ERC20Mock
* move StandardToken.sol to ERC20.sol, likewise test and mock files
* rename MintableToken to ERC20Mintable
* move MintableToken.sol to ERC20Mintable.sol, likewise test and mock files
* rename BurnableToken to ERC20Burnable
* move BurnableToken.sol to ERC20Burnable.sol, likewise for related files
* rename CappedToken to ERC20Capped
* move CappedToken.sol to ERC20Capped.sol, likewise for related files
* rename PausableToken to ERC20Pausable
* move PausableToken.sol to ERC20Pausable.sol, likewise for related files
* rename DetailedERC20 to ERC20Detailed
* move DetailedERC20.sol to ERC20Detailed.sol, likewise for related files
* rename ERC721 to IERC721, and likewise for other related interfaces
* move ERC721.sol to IERC721.sol, likewise for other 721 interfaces
* rename ERC721Token to ERC721
* move ERC721Token.sol to ERC721.sol, likewise for related files
* rename ERC721BasicToken to ERC721Basic
* move ERC721BasicToken.sol to ERC721Basic.sol, likewise for related files
* rename ERC721PausableToken to ERC721Pausable
* move ERC721PausableToken.sol to ERC721Pausable.sol
* rename ERC165 to IERC165
* move ERC165.sol to IERC165.sol
* amend comment that ERC20 is based on FirstBlood
* fix comments mentioning IERC721Receiver
7 years ago
|
|
|
contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
|
|
|
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
|
|
|
|
|
|
beforeEach(async function () {
|
|
|
|
this.token = await ERC20Mock.new(owner, 100);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('total supply', function () {
|
|
|
|
it('returns the total amount of tokens', async function () {
|
|
|
|
(await this.token.totalSupply()).should.be.bignumber.equal(100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('balanceOf', function () {
|
|
|
|
describe('when the requested account has no tokens', function () {
|
|
|
|
it('returns zero', async function () {
|
|
|
|
(await this.token.balanceOf(anotherAccount)).should.be.bignumber.equal(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the requested account has some tokens', function () {
|
|
|
|
it('returns the total amount of tokens', async function () {
|
|
|
|
(await this.token.balanceOf(owner)).should.be.bignumber.equal(100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('transfer', function () {
|
|
|
|
describe('when the recipient is not the zero address', function () {
|
|
|
|
const to = recipient;
|
|
|
|
|
|
|
|
describe('when the sender does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transfer(to, amount, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the sender has enough balance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
it('transfers the requested amount', async function () {
|
|
|
|
await this.token.transfer(to, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.balanceOf(owner)).should.be.bignumber.equal(0);
|
|
|
|
|
|
|
|
(await this.token.balanceOf(to)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits a transfer event', async function () {
|
|
|
|
const { logs } = await this.token.transfer(to, amount, { from: owner });
|
|
|
|
|
|
|
|
const event = expectEvent.inLogs(logs, 'Transfer', {
|
|
|
|
from: owner,
|
|
|
|
to: to,
|
|
|
|
});
|
|
|
|
|
|
|
|
event.args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the recipient is the zero address', function () {
|
|
|
|
const to = ZERO_ADDRESS;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transfer(to, 100, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('approve', function () {
|
|
|
|
describe('when the spender is not the zero address', function () {
|
|
|
|
const spender = recipient;
|
|
|
|
|
|
|
|
describe('when the sender has enough balance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
it('emits an approval event', async function () {
|
|
|
|
const { logs } = await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Approval');
|
|
|
|
logs[0].args.owner.should.equal(owner);
|
|
|
|
logs[0].args.spender.should.equal(spender);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there was no approved amount before', function () {
|
|
|
|
it('approves the requested amount', async function () {
|
|
|
|
await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender had an approved amount', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 1, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('approves the requested amount and replaces the previous one', async function () {
|
|
|
|
await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the sender does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
it('emits an approval event', async function () {
|
|
|
|
const { logs } = await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Approval');
|
|
|
|
logs[0].args.owner.should.equal(owner);
|
|
|
|
logs[0].args.spender.should.equal(spender);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there was no approved amount before', function () {
|
|
|
|
it('approves the requested amount', async function () {
|
|
|
|
await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender had an approved amount', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 1, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('approves the requested amount and replaces the previous one', async function () {
|
|
|
|
await this.token.approve(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender is the zero address', function () {
|
|
|
|
const amount = 100;
|
|
|
|
const spender = ZERO_ADDRESS;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.approve(spender, amount, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('transfer from', function () {
|
|
|
|
const spender = recipient;
|
|
|
|
|
|
|
|
describe('when the recipient is not the zero address', function () {
|
|
|
|
const to = anotherAccount;
|
|
|
|
|
|
|
|
describe('when the spender has enough approved balance', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 100, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the owner has enough balance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
it('transfers the requested amount', async function () {
|
|
|
|
await this.token.transferFrom(owner, to, amount, { from: spender });
|
|
|
|
|
|
|
|
(await this.token.balanceOf(owner)).should.be.bignumber.equal(0);
|
|
|
|
|
|
|
|
(await this.token.balanceOf(to)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decreases the spender allowance', async function () {
|
|
|
|
await this.token.transferFrom(owner, to, amount, { from: spender });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits a transfer event', async function () {
|
|
|
|
const { logs } = await this.token.transferFrom(owner, to, amount, { from: spender });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Transfer');
|
|
|
|
logs[0].args.from.should.equal(owner);
|
|
|
|
logs[0].args.to.should.equal(to);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the owner does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender does not have enough approved balance', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 99, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the owner has enough balance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the owner does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the recipient is the zero address', function () {
|
|
|
|
const amount = 100;
|
|
|
|
const to = ZERO_ADDRESS;
|
|
|
|
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, amount, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.transferFrom(owner, to, amount, { from: spender }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('decrease allowance', function () {
|
|
|
|
describe('when the spender is not the zero address', function () {
|
|
|
|
const spender = recipient;
|
|
|
|
|
|
|
|
function shouldDecreaseApproval (amount) {
|
|
|
|
describe('when there was no approved amount before', function () {
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.decreaseAllowance(spender, amount, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender had an approved amount', function () {
|
|
|
|
const approvedAmount = amount;
|
|
|
|
|
|
|
|
beforeEach(async function () {
|
|
|
|
({ logs: this.logs } = await this.token.approve(spender, approvedAmount, { from: owner }));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits an approval event', async function () {
|
|
|
|
const { logs } = await this.token.decreaseAllowance(spender, approvedAmount, { from: owner });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Approval');
|
|
|
|
logs[0].args.owner.should.equal(owner);
|
|
|
|
logs[0].args.spender.should.equal(spender);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decreases the spender allowance subtracting the requested amount', async function () {
|
|
|
|
await this.token.decreaseAllowance(spender, approvedAmount - 1, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets the allowance to zero when all allowance is removed', async function () {
|
|
|
|
await this.token.decreaseAllowance(spender, approvedAmount, { from: owner });
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reverts when more than the full allowance is removed', async function () {
|
|
|
|
await assertRevert(this.token.decreaseAllowance(spender, approvedAmount + 1, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('when the sender has enough balance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
shouldDecreaseApproval(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the sender does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
shouldDecreaseApproval(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender is the zero address', function () {
|
|
|
|
const amount = 100;
|
|
|
|
const spender = ZERO_ADDRESS;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.decreaseAllowance(spender, amount, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('increase allowance', function () {
|
|
|
|
const amount = 100;
|
|
|
|
|
|
|
|
describe('when the spender is not the zero address', function () {
|
|
|
|
const spender = recipient;
|
|
|
|
|
|
|
|
describe('when the sender has enough balance', function () {
|
|
|
|
it('emits an approval event', async function () {
|
|
|
|
const { logs } = await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Approval');
|
|
|
|
logs[0].args.owner.should.equal(owner);
|
|
|
|
logs[0].args.spender.should.equal(spender);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there was no approved amount before', function () {
|
|
|
|
it('approves the requested amount', async function () {
|
|
|
|
await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender had an approved amount', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 1, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('increases the spender allowance adding the requested amount', async function () {
|
|
|
|
await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount + 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the sender does not have enough balance', function () {
|
|
|
|
const amount = 101;
|
|
|
|
|
|
|
|
it('emits an approval event', async function () {
|
|
|
|
const { logs } = await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
logs.length.should.equal(1);
|
|
|
|
logs[0].event.should.equal('Approval');
|
|
|
|
logs[0].args.owner.should.equal(owner);
|
|
|
|
logs[0].args.spender.should.equal(spender);
|
|
|
|
logs[0].args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there was no approved amount before', function () {
|
|
|
|
it('approves the requested amount', async function () {
|
|
|
|
await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender had an approved amount', function () {
|
|
|
|
beforeEach(async function () {
|
|
|
|
await this.token.approve(spender, 1, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('increases the spender allowance adding the requested amount', async function () {
|
|
|
|
await this.token.increaseAllowance(spender, amount, { from: owner });
|
|
|
|
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount + 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the spender is the zero address', function () {
|
|
|
|
const spender = ZERO_ADDRESS;
|
|
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
|
await assertRevert(this.token.increaseAllowance(spender, amount, { from: owner }));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('_mint', function () {
|
|
|
|
const initialSupply = new BigNumber(100);
|
|
|
|
const amount = new BigNumber(50);
|
|
|
|
|
|
|
|
it('rejects a null account', async function () {
|
|
|
|
await assertRevert(this.token.mint(ZERO_ADDRESS, amount));
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for a non null account', function () {
|
|
|
|
beforeEach('minting', async function () {
|
|
|
|
const { logs } = await this.token.mint(recipient, amount);
|
|
|
|
this.logs = logs;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('increments totalSupply', async function () {
|
|
|
|
const expectedSupply = initialSupply.plus(amount);
|
|
|
|
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('increments recipient balance', async function () {
|
|
|
|
(await this.token.balanceOf(recipient)).should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits Transfer event', async function () {
|
|
|
|
const event = expectEvent.inLogs(this.logs, 'Transfer', {
|
|
|
|
from: ZERO_ADDRESS,
|
|
|
|
to: recipient,
|
|
|
|
});
|
|
|
|
|
|
|
|
event.args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('_burn', function () {
|
|
|
|
const initialSupply = new BigNumber(100);
|
|
|
|
|
|
|
|
it('rejects a null account', async function () {
|
|
|
|
await assertRevert(this.token.burn(ZERO_ADDRESS, 1));
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for a non null account', function () {
|
|
|
|
it('rejects burning more than balance', async function () {
|
|
|
|
await assertRevert(this.token.burn(owner, initialSupply.plus(1)));
|
|
|
|
});
|
|
|
|
|
|
|
|
const describeBurn = function (description, amount) {
|
|
|
|
describe(description, function () {
|
|
|
|
beforeEach('burning', async function () {
|
|
|
|
const { logs } = await this.token.burn(owner, amount);
|
|
|
|
this.logs = logs;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decrements totalSupply', async function () {
|
|
|
|
const expectedSupply = initialSupply.minus(amount);
|
|
|
|
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decrements owner balance', async function () {
|
|
|
|
const expectedBalance = initialSupply.minus(amount);
|
|
|
|
(await this.token.balanceOf(owner)).should.be.bignumber.equal(expectedBalance);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits Transfer event', async function () {
|
|
|
|
const event = expectEvent.inLogs(this.logs, 'Transfer', {
|
|
|
|
from: owner,
|
|
|
|
to: ZERO_ADDRESS,
|
|
|
|
});
|
|
|
|
|
|
|
|
event.args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describeBurn('for entire balance', initialSupply);
|
|
|
|
describeBurn('for less amount than balance', initialSupply.sub(1));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('_burnFrom', function () {
|
|
|
|
const initialSupply = new BigNumber(100);
|
|
|
|
const allowance = new BigNumber(70);
|
|
|
|
|
|
|
|
const spender = anotherAccount;
|
|
|
|
|
|
|
|
beforeEach('approving', async function () {
|
|
|
|
await this.token.approve(spender, allowance, { from: owner });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects a null account', async function () {
|
|
|
|
await assertRevert(this.token.burnFrom(ZERO_ADDRESS, 1));
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('for a non null account', function () {
|
|
|
|
it('rejects burning more than allowance', async function () {
|
|
|
|
await assertRevert(this.token.burnFrom(owner, allowance.plus(1)));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects burning more than balance', async function () {
|
|
|
|
await assertRevert(this.token.burnFrom(owner, initialSupply.plus(1)));
|
|
|
|
});
|
|
|
|
|
|
|
|
const describeBurnFrom = function (description, amount) {
|
|
|
|
describe(description, function () {
|
|
|
|
beforeEach('burning', async function () {
|
|
|
|
const { logs } = await this.token.burnFrom(owner, amount, { from: spender });
|
|
|
|
this.logs = logs;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decrements totalSupply', async function () {
|
|
|
|
const expectedSupply = initialSupply.minus(amount);
|
|
|
|
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decrements owner balance', async function () {
|
|
|
|
const expectedBalance = initialSupply.minus(amount);
|
|
|
|
(await this.token.balanceOf(owner)).should.be.bignumber.equal(expectedBalance);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('decrements spender allowance', async function () {
|
|
|
|
const expectedAllowance = allowance.minus(amount);
|
|
|
|
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(expectedAllowance);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('emits Transfer event', async function () {
|
|
|
|
const event = expectEvent.inLogs(this.logs, 'Transfer', {
|
|
|
|
from: owner,
|
|
|
|
to: ZERO_ADDRESS,
|
|
|
|
});
|
|
|
|
|
|
|
|
event.args.value.should.be.bignumber.equal(amount);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describeBurnFrom('for entire allowance', allowance);
|
|
|
|
describeBurnFrom('for less amount than allowance', allowance.sub(1));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|