Skip to content

Commit

Permalink
getApproved require the given token ID exist (#1256)
Browse files Browse the repository at this point in the history
* getApproved require the given token ID exist

* missing commit from merge

* clarify the test descriptions
  • Loading branch information
lamengao authored and nventuro committed Sep 6, 2018
1 parent 661e5d8 commit a7ee54e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions contracts/token/ERC721/ERC721Basic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ contract ERC721Basic is ERC165, IERC721Basic {

/**
* @dev Gets the approved address for a token ID, or zero if no address set
* Reverts if the token ID does not exist.
* @param _tokenId uint256 ID of the token to query the approval of
* @return address currently approved for the given token ID
*/
function getApproved(uint256 _tokenId) public view returns (address) {
require(_exists(_tokenId));
return tokenApprovals_[_tokenId];
}

Expand Down
8 changes: 5 additions & 3 deletions test/token/ERC721/ERC721MintBurn.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) {
});
});

describe('when there is a previous approval', function () {
describe('when there is a previous approval burned', function () {
beforeEach(async function () {
await this.token.approve(accounts[1], tokenId, { from: sender });
const result = await this.token.burn(tokenId, { from: sender });
logs = result.logs;
});

it('clears the approval', async function () {
(await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS);
context('getApproved', function () {
it('reverts', async function () {
await assertRevert(this.token.getApproved(tokenId));
});
});
});

Expand Down

0 comments on commit a7ee54e

Please sign in to comment.