Skip to content

Commit

Permalink
Improve revert reason when assuming interface compliance OpenZeppelin…
Browse files Browse the repository at this point in the history
  • Loading branch information
NoopurShinde committed Oct 11, 2019
1 parent 1ca3742 commit 3d96ecf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
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;

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

0 comments on commit 3d96ecf

Please sign in to comment.