|
@@ -6,8 +6,10 @@ const { shouldSupportInterfaces } = require('../../utils/introspection/SupportsI
|
|
|
|
|
|
const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock');
|
|
|
|
|
|
-const Error = [ 'None', 'RevertWithMessage', 'RevertWithoutMessage', 'Panic' ]
|
|
|
- .reduce((acc, entry, idx) => Object.assign({ [entry]: idx }, acc), {});
|
|
|
+const Error = ['None', 'RevertWithMessage', 'RevertWithoutMessage', 'Panic'].reduce(
|
|
|
+ (acc, entry, idx) => Object.assign({ [entry]: idx }, acc),
|
|
|
+ {},
|
|
|
+);
|
|
|
|
|
|
const firstTokenId = new BN('5042');
|
|
|
const secondTokenId = new BN('79217');
|
|
@@ -17,11 +19,8 @@ const baseURI = 'https://api.example.com/v1/';
|
|
|
|
|
|
const RECEIVER_MAGIC_VALUE = '0x150b7a02';
|
|
|
|
|
|
-function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, anotherApproved, operator, other) {
|
|
|
- shouldSupportInterfaces([
|
|
|
- 'ERC165',
|
|
|
- 'ERC721',
|
|
|
- ]);
|
|
|
+function shouldBehaveLikeERC721(errorPrefix, owner, newOwner, approved, anotherApproved, operator, other) {
|
|
|
+ shouldSupportInterfaces(['ERC165', 'ERC721']);
|
|
|
|
|
|
context('with minted tokens', function () {
|
|
|
beforeEach(async function () {
|
|
@@ -45,9 +44,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
context('when querying the zero address', function () {
|
|
|
it('throws', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.balanceOf(ZERO_ADDRESS), 'ERC721: address zero is not a valid owner',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.balanceOf(ZERO_ADDRESS), 'ERC721: address zero is not a valid owner');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -65,9 +62,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
const tokenId = nonExistentTokenId;
|
|
|
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.ownerOf(tokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.ownerOf(tokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -112,21 +107,21 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
const shouldTransferTokensByUsers = function (transferFunction) {
|
|
|
context('when called by the owner', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: owner }));
|
|
|
+ receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: owner });
|
|
|
});
|
|
|
transferWasSuccessful({ owner, tokenId, approved });
|
|
|
});
|
|
|
|
|
|
context('when called by the approved individual', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: approved }));
|
|
|
+ receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: approved });
|
|
|
});
|
|
|
transferWasSuccessful({ owner, tokenId, approved });
|
|
|
});
|
|
|
|
|
|
context('when called by the operator', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator }));
|
|
|
+ receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator });
|
|
|
});
|
|
|
transferWasSuccessful({ owner, tokenId, approved });
|
|
|
});
|
|
@@ -134,14 +129,14 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when called by the owner without an approved user', function () {
|
|
|
beforeEach(async function () {
|
|
|
await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner });
|
|
|
- (receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator }));
|
|
|
+ receipt = await transferFunction.call(this, owner, this.toWhom, tokenId, { from: operator });
|
|
|
});
|
|
|
transferWasSuccessful({ owner, tokenId, approved: null });
|
|
|
});
|
|
|
|
|
|
context('when sent to the owner', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await transferFunction.call(this, owner, owner, tokenId, { from: owner }));
|
|
|
+ receipt = await transferFunction.call(this, owner, owner, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
it('keeps ownership of the token', async function () {
|
|
@@ -166,12 +161,11 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
it('keeps same tokens by index', async function () {
|
|
|
if (!this.token.tokenOfOwnerByIndex) return;
|
|
|
- const tokensListed = await Promise.all(
|
|
|
- [0, 1].map(i => this.token.tokenOfOwnerByIndex(owner, i)),
|
|
|
- );
|
|
|
- expect(tokensListed.map(t => t.toNumber())).to.have.members(
|
|
|
- [firstTokenId.toNumber(), secondTokenId.toNumber()],
|
|
|
- );
|
|
|
+ const tokensListed = await Promise.all([0, 1].map(i => this.token.tokenOfOwnerByIndex(owner, i)));
|
|
|
+ expect(tokensListed.map(t => t.toNumber())).to.have.members([
|
|
|
+ firstTokenId.toNumber(),
|
|
|
+ secondTokenId.toNumber(),
|
|
|
+ ]);
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -265,13 +259,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
describe('with an invalid token id', function () {
|
|
|
it('reverts', async function () {
|
|
|
await expectRevert(
|
|
|
- transferFun.call(
|
|
|
- this,
|
|
|
- owner,
|
|
|
- this.receiver.address,
|
|
|
- nonExistentTokenId,
|
|
|
- { from: owner },
|
|
|
- ),
|
|
|
+ transferFun.call(this, owner, this.receiver.address, nonExistentTokenId, { from: owner }),
|
|
|
'ERC721: invalid token ID',
|
|
|
);
|
|
|
});
|
|
@@ -342,7 +330,8 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
const tokenId = fourthTokenId;
|
|
|
const data = '0x42';
|
|
|
|
|
|
- describe('via safeMint', function () { // regular minting is tested in ERC721Mintable.test.js and others
|
|
|
+ describe('via safeMint', function () {
|
|
|
+ // regular minting is tested in ERC721Mintable.test.js and others
|
|
|
it('calls onERC721Received — with data', async function () {
|
|
|
this.receiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, Error.None);
|
|
|
const receipt = await this.token.$_safeMint(this.receiver.address, tokenId, data);
|
|
@@ -397,9 +386,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('to a receiver contract that panics', function () {
|
|
|
it('reverts', async function () {
|
|
|
const revertingReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, Error.Panic);
|
|
|
- await expectRevert.unspecified(
|
|
|
- this.token.$_safeMint(revertingReceiver.address, tokenId),
|
|
|
- );
|
|
|
+ await expectRevert.unspecified(this.token.$_safeMint(revertingReceiver.address, tokenId));
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -445,7 +432,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when clearing approval', function () {
|
|
|
context('when there was no prior approval', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner }));
|
|
|
+ receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
itClearsApproval();
|
|
@@ -455,7 +442,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when there was a prior approval', function () {
|
|
|
beforeEach(async function () {
|
|
|
await this.token.approve(approved, tokenId, { from: owner });
|
|
|
- (receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner }));
|
|
|
+ receipt = await this.token.approve(ZERO_ADDRESS, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
itClearsApproval();
|
|
@@ -466,7 +453,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when approving a non-zero address', function () {
|
|
|
context('when there was no prior approval', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (receipt = await this.token.approve(approved, tokenId, { from: owner }));
|
|
|
+ receipt = await this.token.approve(approved, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
itApproves(approved);
|
|
@@ -476,7 +463,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when there was a prior approval to the same address', function () {
|
|
|
beforeEach(async function () {
|
|
|
await this.token.approve(approved, tokenId, { from: owner });
|
|
|
- (receipt = await this.token.approve(approved, tokenId, { from: owner }));
|
|
|
+ receipt = await this.token.approve(approved, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
itApproves(approved);
|
|
@@ -486,7 +473,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
context('when there was a prior approval to a different address', function () {
|
|
|
beforeEach(async function () {
|
|
|
await this.token.approve(anotherApproved, tokenId, { from: owner });
|
|
|
- (receipt = await this.token.approve(anotherApproved, tokenId, { from: owner }));
|
|
|
+ receipt = await this.token.approve(anotherApproved, tokenId, { from: owner });
|
|
|
});
|
|
|
|
|
|
itApproves(anotherApproved);
|
|
@@ -496,31 +483,33 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
context('when the address that receives the approval is the owner', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.approve(owner, tokenId, { from: owner }), 'ERC721: approval to current owner',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.approve(owner, tokenId, { from: owner }), 'ERC721: approval to current owner');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
context('when the sender does not own the given token ID', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(this.token.approve(approved, tokenId, { from: other }),
|
|
|
- 'ERC721: approve caller is not token owner or approved');
|
|
|
+ await expectRevert(
|
|
|
+ this.token.approve(approved, tokenId, { from: other }),
|
|
|
+ 'ERC721: approve caller is not token owner or approved',
|
|
|
+ );
|
|
|
});
|
|
|
});
|
|
|
|
|
|
context('when the sender is approved for the given token ID', function () {
|
|
|
it('reverts', async function () {
|
|
|
await this.token.approve(approved, tokenId, { from: owner });
|
|
|
- await expectRevert(this.token.approve(anotherApproved, tokenId, { from: approved }),
|
|
|
- 'ERC721: approve caller is not token owner or approved for all');
|
|
|
+ await expectRevert(
|
|
|
+ this.token.approve(anotherApproved, tokenId, { from: approved }),
|
|
|
+ 'ERC721: approve caller is not token owner or approved for all',
|
|
|
+ );
|
|
|
});
|
|
|
});
|
|
|
|
|
|
context('when the sender is an operator', function () {
|
|
|
beforeEach(async function () {
|
|
|
await this.token.setApprovalForAll(operator, true, { from: owner });
|
|
|
- (receipt = await this.token.approve(approved, tokenId, { from: operator }));
|
|
|
+ receipt = await this.token.approve(approved, tokenId, { from: operator });
|
|
|
});
|
|
|
|
|
|
itApproves(approved);
|
|
@@ -529,8 +518,10 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
context('when the given token ID does not exist', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(this.token.approve(approved, nonExistentTokenId, { from: operator }),
|
|
|
- 'ERC721: invalid token ID');
|
|
|
+ await expectRevert(
|
|
|
+ this.token.approve(approved, nonExistentTokenId, { from: operator }),
|
|
|
+ 'ERC721: invalid token ID',
|
|
|
+ );
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -608,8 +599,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
context('when the operator is the owner', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(this.token.setApprovalForAll(owner, true, { from: owner }),
|
|
|
- 'ERC721: approve to caller');
|
|
|
+ await expectRevert(this.token.setApprovalForAll(owner, true, { from: owner }), 'ERC721: approve to caller');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -617,18 +607,13 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
describe('getApproved', async function () {
|
|
|
context('when token is not minted', async function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.getApproved(nonExistentTokenId),
|
|
|
- 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.getApproved(nonExistentTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
context('when token has been minted ', async function () {
|
|
|
it('should return the zero address', async function () {
|
|
|
- expect(await this.token.getApproved(firstTokenId)).to.be.equal(
|
|
|
- ZERO_ADDRESS,
|
|
|
- );
|
|
|
+ expect(await this.token.getApproved(firstTokenId)).to.be.equal(ZERO_ADDRESS);
|
|
|
});
|
|
|
|
|
|
context('when account has been approved', async function () {
|
|
@@ -646,14 +631,12 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
describe('_mint(address, uint256)', function () {
|
|
|
it('reverts with a null destination address', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.$_mint(ZERO_ADDRESS, firstTokenId), 'ERC721: mint to the zero address',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.$_mint(ZERO_ADDRESS, firstTokenId), 'ERC721: mint to the zero address');
|
|
|
});
|
|
|
|
|
|
context('with minted token', async function () {
|
|
|
beforeEach(async function () {
|
|
|
- (this.receipt = await this.token.$_mint(owner, firstTokenId));
|
|
|
+ this.receipt = await this.token.$_mint(owner, firstTokenId);
|
|
|
});
|
|
|
|
|
|
it('emits a Transfer event', function () {
|
|
@@ -673,9 +656,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
describe('_burn', function () {
|
|
|
it('reverts when burning a non-existent token id', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.$_burn(nonExistentTokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.$_burn(nonExistentTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
|
|
|
context('with minted tokens', function () {
|
|
@@ -686,7 +667,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
context('with burnt token', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (this.receipt = await this.token.$_burn(firstTokenId));
|
|
|
+ this.receipt = await this.token.$_burn(firstTokenId);
|
|
|
});
|
|
|
|
|
|
it('emits a Transfer event', function () {
|
|
@@ -695,25 +676,19 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
|
|
|
|
|
|
it('deletes the token', async function () {
|
|
|
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('1');
|
|
|
- await expectRevert(
|
|
|
- this.token.ownerOf(firstTokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.ownerOf(firstTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
|
|
|
it('reverts when burning a token id that has been deleted', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.$_burn(firstTokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.$_burn(firstTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approved, anotherApproved, operator, other) {
|
|
|
- shouldSupportInterfaces([
|
|
|
- 'ERC721Enumerable',
|
|
|
- ]);
|
|
|
+function shouldBehaveLikeERC721Enumerable(errorPrefix, owner, newOwner, approved, anotherApproved, operator, other) {
|
|
|
+ shouldSupportInterfaces(['ERC721Enumerable']);
|
|
|
|
|
|
context('with minted tokens', function () {
|
|
|
beforeEach(async function () {
|
|
@@ -737,17 +712,13 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
describe('when the index is greater than or equal to the total tokens owned by the given address', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenOfOwnerByIndex(owner, 2), 'ERC721Enumerable: owner index out of bounds',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenOfOwnerByIndex(owner, 2), 'ERC721Enumerable: owner index out of bounds');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('when the given address does not own any token', function () {
|
|
|
it('reverts', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenOfOwnerByIndex(other, 0), 'ERC721Enumerable: owner index out of bounds',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenOfOwnerByIndex(other, 0), 'ERC721Enumerable: owner index out of bounds');
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -759,35 +730,31 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
it('returns correct token IDs for target', async function () {
|
|
|
expect(await this.token.balanceOf(other)).to.be.bignumber.equal('2');
|
|
|
- const tokensListed = await Promise.all(
|
|
|
- [0, 1].map(i => this.token.tokenOfOwnerByIndex(other, i)),
|
|
|
- );
|
|
|
- expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(),
|
|
|
- secondTokenId.toNumber()]);
|
|
|
+ const tokensListed = await Promise.all([0, 1].map(i => this.token.tokenOfOwnerByIndex(other, i)));
|
|
|
+ expect(tokensListed.map(t => t.toNumber())).to.have.members([
|
|
|
+ firstTokenId.toNumber(),
|
|
|
+ secondTokenId.toNumber(),
|
|
|
+ ]);
|
|
|
});
|
|
|
|
|
|
it('returns empty collection for original owner', async function () {
|
|
|
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('0');
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenOfOwnerByIndex(owner, 0), 'ERC721Enumerable: owner index out of bounds',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenOfOwnerByIndex(owner, 0), 'ERC721Enumerable: owner index out of bounds');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('tokenByIndex', function () {
|
|
|
it('returns all tokens', async function () {
|
|
|
- const tokensListed = await Promise.all(
|
|
|
- [0, 1].map(i => this.token.tokenByIndex(i)),
|
|
|
- );
|
|
|
- expect(tokensListed.map(t => t.toNumber())).to.have.members([firstTokenId.toNumber(),
|
|
|
- secondTokenId.toNumber()]);
|
|
|
+ const tokensListed = await Promise.all([0, 1].map(i => this.token.tokenByIndex(i)));
|
|
|
+ expect(tokensListed.map(t => t.toNumber())).to.have.members([
|
|
|
+ firstTokenId.toNumber(),
|
|
|
+ secondTokenId.toNumber(),
|
|
|
+ ]);
|
|
|
});
|
|
|
|
|
|
it('reverts if index is greater than supply', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenByIndex(2), 'ERC721Enumerable: global index out of bounds',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenByIndex(2), 'ERC721Enumerable: global index out of bounds');
|
|
|
});
|
|
|
|
|
|
[firstTokenId, secondTokenId].forEach(function (tokenId) {
|
|
@@ -801,11 +768,9 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
expect(await this.token.totalSupply()).to.be.bignumber.equal('3');
|
|
|
|
|
|
- const tokensListed = await Promise.all(
|
|
|
- [0, 1, 2].map(i => this.token.tokenByIndex(i)),
|
|
|
- );
|
|
|
+ const tokensListed = await Promise.all([0, 1, 2].map(i => this.token.tokenByIndex(i)));
|
|
|
const expectedTokens = [firstTokenId, secondTokenId, newTokenId, anotherNewTokenId].filter(
|
|
|
- x => (x !== tokenId),
|
|
|
+ x => x !== tokenId,
|
|
|
);
|
|
|
expect(tokensListed.map(t => t.toNumber())).to.have.members(expectedTokens.map(t => t.toNumber()));
|
|
|
});
|
|
@@ -815,14 +780,12 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
describe('_mint(address, uint256)', function () {
|
|
|
it('reverts with a null destination address', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.$_mint(ZERO_ADDRESS, firstTokenId), 'ERC721: mint to the zero address',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.$_mint(ZERO_ADDRESS, firstTokenId), 'ERC721: mint to the zero address');
|
|
|
});
|
|
|
|
|
|
context('with minted token', async function () {
|
|
|
beforeEach(async function () {
|
|
|
- (this.receipt = await this.token.$_mint(owner, firstTokenId));
|
|
|
+ this.receipt = await this.token.$_mint(owner, firstTokenId);
|
|
|
});
|
|
|
|
|
|
it('adjusts owner tokens by index', async function () {
|
|
@@ -837,9 +800,7 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
describe('_burn', function () {
|
|
|
it('reverts when burning a non-existent token id', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.$_burn(firstTokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.$_burn(firstTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
|
|
|
context('with minted tokens', function () {
|
|
@@ -850,7 +811,7 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
|
|
|
context('with burnt token', function () {
|
|
|
beforeEach(async function () {
|
|
|
- (this.receipt = await this.token.$_burn(firstTokenId));
|
|
|
+ this.receipt = await this.token.$_burn(firstTokenId);
|
|
|
});
|
|
|
|
|
|
it('removes that token from the token list of the owner', async function () {
|
|
@@ -864,19 +825,15 @@ function shouldBehaveLikeERC721Enumerable (errorPrefix, owner, newOwner, approve
|
|
|
it('burns all tokens', async function () {
|
|
|
await this.token.$_burn(secondTokenId, { from: owner });
|
|
|
expect(await this.token.totalSupply()).to.be.bignumber.equal('0');
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenByIndex(0), 'ERC721Enumerable: global index out of bounds',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenByIndex(0), 'ERC721Enumerable: global index out of bounds');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function shouldBehaveLikeERC721Metadata (errorPrefix, name, symbol, owner) {
|
|
|
- shouldSupportInterfaces([
|
|
|
- 'ERC721Metadata',
|
|
|
- ]);
|
|
|
+function shouldBehaveLikeERC721Metadata(errorPrefix, name, symbol, owner) {
|
|
|
+ shouldSupportInterfaces(['ERC721Metadata']);
|
|
|
|
|
|
describe('metadata', function () {
|
|
|
it('has a name', async function () {
|
|
@@ -897,9 +854,7 @@ function shouldBehaveLikeERC721Metadata (errorPrefix, name, symbol, owner) {
|
|
|
});
|
|
|
|
|
|
it('reverts when queried for non existent token id', async function () {
|
|
|
- await expectRevert(
|
|
|
- this.token.tokenURI(nonExistentTokenId), 'ERC721: invalid token ID',
|
|
|
- );
|
|
|
+ await expectRevert(this.token.tokenURI(nonExistentTokenId), 'ERC721: invalid token ID');
|
|
|
});
|
|
|
|
|
|
describe('base URI', function () {
|