Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1727: Improve revert reason when assuming interface compliance contracts. #1943

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Improve revert reason when assuming interface compliance #1727
  • Loading branch information
NoopurShinde committed Oct 11, 2019
commit 3d96ecfd5267a56cc67261c3c3f3d04fa2724806
5 changes: 0 additions & 5 deletions contracts/Migrations.sol

This file was deleted.

11 changes: 10 additions & 1 deletion contracts/mocks/ERC721ReceiverNotImplementedMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@ pragma solidity ^0.5.0;


contract ERC721ReceiverNotImplementedMock{

bytes4 private _retval;
bool private _reverts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these two variables since they're not used.


event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);

constructor (bytes4 retval, bool reverts) public {
_retval = retval;
_reverts = reverts;
}

}
6 changes: 3 additions & 3 deletions test/token/ERC721/ERC721.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function shouldBehaveLikeERC721 (

describe('to a receiver contract returning unexpected value', function () {
it('reverts', async function () {
const noReceiverImplemented = await ERC721NoReceiverMock.new();
const noReceiverImplemented = await ERC721NoReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
await expectRevert(
this.token.safeTransferFrom(owner, noReceiverImplemented.address, tokenId, { from: owner }),
'ERC721: to address does not implement ERC721Received interface'
Expand All @@ -320,7 +320,7 @@ function shouldBehaveLikeERC721 (

describe('to a contract that does not implement the required function', function () {
it('reverts', async function () {
const noReceiverImplemented = await ERC721NoReceiverMock.new();
const noReceiverImplemented = await ERC721NoReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
await expectRevert(
this.token.safeTransferFrom(owner, noReceiverImplemented.address, tokenId, { from: owner }),
'ERC721: to address does not implement ERC721Received interface'
Expand Down Expand Up @@ -369,7 +369,7 @@ function shouldBehaveLikeERC721 (

context('to a receiver contract returning unexpected value', function () {
it('reverts', async function () {
const noReceiverImplemented = await ERC721NoReceiverMock.new();
const noReceiverImplemented = await ERC721NoReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
await expectRevert(
this.ERC721Mock.safeMint(noReceiverImplemented.address, tokenId),
'ERC721: to address does not implement ERC721Received interface'
Expand Down