|
@@ -6,7 +6,7 @@ const { expect } = require('chai');
|
|
|
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
|
|
|
const ERC721Mock = artifacts.require('ERC721Mock.sol');
|
|
|
|
|
|
-contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
+contract('ERC721', function ([_, creator, owner, other, ...accounts]) {
|
|
|
beforeEach(async function () {
|
|
|
this.token = await ERC721Mock.new({ from: creator });
|
|
|
});
|
|
@@ -25,20 +25,20 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
|
|
|
context('with minted token', async function () {
|
|
|
beforeEach(async function () {
|
|
|
- ({ logs: this.logs } = await this.token.mint(tokenOwner, tokenId));
|
|
|
+ ({ logs: this.logs } = await this.token.mint(owner, tokenId));
|
|
|
});
|
|
|
|
|
|
it('emits a Transfer event', function () {
|
|
|
- expectEvent.inLogs(this.logs, 'Transfer', { from: ZERO_ADDRESS, to: tokenOwner, tokenId });
|
|
|
+ expectEvent.inLogs(this.logs, 'Transfer', { from: ZERO_ADDRESS, to: owner, tokenId });
|
|
|
});
|
|
|
|
|
|
it('creates the token', async function () {
|
|
|
- expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('1');
|
|
|
- expect(await this.token.ownerOf(tokenId)).to.equal(tokenOwner);
|
|
|
+ expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('1');
|
|
|
+ expect(await this.token.ownerOf(tokenId)).to.equal(owner);
|
|
|
});
|
|
|
|
|
|
it('reverts when adding a token id that already exists', async function () {
|
|
|
- await expectRevert(this.token.mint(tokenOwner, tokenId), 'ERC721: token already minted');
|
|
|
+ await expectRevert(this.token.mint(owner, tokenId), 'ERC721: token already minted');
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -46,13 +46,13 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
describe('_burn(address, uint256)', function () {
|
|
|
it('reverts when burning a non-existent token id', async function () {
|
|
|
await expectRevert(
|
|
|
- this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), 'ERC721: owner query for nonexistent token'
|
|
|
+ this.token.methods['burn(address,uint256)'](owner, tokenId), 'ERC721: owner query for nonexistent token'
|
|
|
);
|
|
|
});
|
|
|
|
|
|
context('with minted token', function () {
|
|
|
beforeEach(async function () {
|
|
|
- await this.token.mint(tokenOwner, tokenId);
|
|
|
+ await this.token.mint(owner, tokenId);
|
|
|
});
|
|
|
|
|
|
it('reverts when the account is not the owner', async function () {
|
|
@@ -63,15 +63,15 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
|
|
|
context('with burnt token', function () {
|
|
|
beforeEach(async function () {
|
|
|
- ({ logs: this.logs } = await this.token.methods['burn(address,uint256)'](tokenOwner, tokenId));
|
|
|
+ ({ logs: this.logs } = await this.token.methods['burn(address,uint256)'](owner, tokenId));
|
|
|
});
|
|
|
|
|
|
it('emits a Transfer event', function () {
|
|
|
- expectEvent.inLogs(this.logs, 'Transfer', { from: tokenOwner, to: ZERO_ADDRESS, tokenId });
|
|
|
+ expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId });
|
|
|
});
|
|
|
|
|
|
it('deletes the token', async function () {
|
|
|
- expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0');
|
|
|
+ expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('0');
|
|
|
await expectRevert(
|
|
|
this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token'
|
|
|
);
|
|
@@ -79,7 +79,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
|
|
|
it('reverts when burning a token id that has been deleted', async function () {
|
|
|
await expectRevert(
|
|
|
- this.token.methods['burn(address,uint256)'](tokenOwner, tokenId),
|
|
|
+ this.token.methods['burn(address,uint256)'](owner, tokenId),
|
|
|
'ERC721: owner query for nonexistent token'
|
|
|
);
|
|
|
});
|
|
@@ -96,7 +96,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
|
|
|
context('with minted token', function () {
|
|
|
beforeEach(async function () {
|
|
|
- await this.token.mint(tokenOwner, tokenId);
|
|
|
+ await this.token.mint(owner, tokenId);
|
|
|
});
|
|
|
|
|
|
context('with burnt token', function () {
|
|
@@ -105,11 +105,11 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) {
|
|
|
});
|
|
|
|
|
|
it('emits a Transfer event', function () {
|
|
|
- expectEvent.inLogs(this.logs, 'Transfer', { from: tokenOwner, to: ZERO_ADDRESS, tokenId });
|
|
|
+ expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, tokenId });
|
|
|
});
|
|
|
|
|
|
it('deletes the token', async function () {
|
|
|
- expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0');
|
|
|
+ expect(await this.token.balanceOf(owner)).to.be.bignumber.equal('0');
|
|
|
await expectRevert(
|
|
|
this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token'
|
|
|
);
|