Commit a7ee54e1 by Bing Yi Committed by Nicolás Venturo

getApproved require the given token ID exist (#1256)

* getApproved require the given token ID exist

* missing commit from merge

* clarify the test descriptions
parent 661e5d86
...@@ -93,10 +93,12 @@ contract ERC721Basic is ERC165, IERC721Basic { ...@@ -93,10 +93,12 @@ contract ERC721Basic is ERC165, IERC721Basic {
/** /**
* @dev Gets the approved address for a token ID, or zero if no address set * @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 * @param _tokenId uint256 ID of the token to query the approval of
* @return address currently approved for the given token ID * @return address currently approved for the given token ID
*/ */
function getApproved(uint256 _tokenId) public view returns (address) { function getApproved(uint256 _tokenId) public view returns (address) {
require(_exists(_tokenId));
return tokenApprovals_[_tokenId]; return tokenApprovals_[_tokenId];
} }
......
...@@ -84,15 +84,17 @@ function shouldBehaveLikeMintAndBurnERC721 (accounts) { ...@@ -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 () { beforeEach(async function () {
await this.token.approve(accounts[1], tokenId, { from: sender }); await this.token.approve(accounts[1], tokenId, { from: sender });
const result = await this.token.burn(tokenId, { from: sender }); const result = await this.token.burn(tokenId, { from: sender });
logs = result.logs; logs = result.logs;
}); });
it('clears the approval', async function () { context('getApproved', function () {
(await this.token.getApproved(tokenId)).should.be.equal(ZERO_ADDRESS); it('reverts', async function () {
await assertRevert(this.token.getApproved(tokenId));
});
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment