Change behavior of ceilDiv(0, 0) and improve test coverage (#4348)
This commit is contained in:
@ -6,7 +6,7 @@ const { expectRevertCustomError } = require('../../../helpers/customError');
|
||||
const ERC721Burnable = artifacts.require('$ERC721Burnable');
|
||||
|
||||
contract('ERC721Burnable', function (accounts) {
|
||||
const [owner, approved] = accounts;
|
||||
const [owner, approved, another] = accounts;
|
||||
|
||||
const firstTokenId = new BN(1);
|
||||
const secondTokenId = new BN(2);
|
||||
@ -61,6 +61,15 @@ contract('ERC721Burnable', function (accounts) {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when there is no previous approval burned', function () {
|
||||
it('reverts', async function () {
|
||||
await expectRevertCustomError(this.token.burn(tokenId, { from: another }), 'ERC721InsufficientApproval', [
|
||||
another,
|
||||
tokenId,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the given token ID was not tracked by this contract', function () {
|
||||
it('reverts', async function () {
|
||||
await expectRevertCustomError(this.token.burn(unknownTokenId, { from: owner }), 'ERC721NonexistentToken', [
|
||||
|
||||
@ -85,6 +85,14 @@ contract('ERC721Consecutive', function (accounts) {
|
||||
expect(await this.token.getVotes(account)).to.be.bignumber.equal(web3.utils.toBN(balance));
|
||||
}
|
||||
});
|
||||
|
||||
it('reverts on consecutive minting to the zero address', async function () {
|
||||
await expectRevertCustomError(
|
||||
ERC721ConsecutiveMock.new(name, symbol, offset, delegates, [ZERO_ADDRESS], [10]),
|
||||
'ERC721InvalidReceiver',
|
||||
[ZERO_ADDRESS],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('minting after construction', function () {
|
||||
@ -172,6 +180,17 @@ contract('ERC721Consecutive', function (accounts) {
|
||||
expect(await this.token.$_exists(tokenId)).to.be.equal(true);
|
||||
expect(await this.token.ownerOf(tokenId), user2);
|
||||
});
|
||||
|
||||
it('reverts burning batches of size != 1', async function () {
|
||||
const tokenId = batches[0].amount + offset;
|
||||
const receiver = batches[0].receiver;
|
||||
|
||||
await expectRevertCustomError(
|
||||
this.token.$_afterTokenTransfer(receiver, ZERO_ADDRESS, tokenId, 2),
|
||||
'ERC721ForbiddenBatchBurn',
|
||||
[],
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user