-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Add the missing test for ERC721Holder #1249
Conversation
|
||
function shouldBehaveLikeERC721Holder (accounts) { | ||
const tokenId = 1; | ||
const creator = accounts[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π±
Consider destructuring the accounts
array (e.g. change the function declaration to function shouldBehaveLikeERC721Holder ([creator])
), see #1137 for reference π
require('chai') | ||
.should(); | ||
|
||
function shouldBehaveLikeERC721Holder (accounts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this name is accurate: the token isn't behaving like an ERC721 Holder, it is instead interacting with one.
I think we should have a test for the receiver itself, that calls the function and checks the return value, and one for the token, checking that safeTransferFrom
works properly (i.e. rejects an invalid return value, accepts the correct one). @shrugs is the local ERC721 expert though, so I'll defer to his wisdom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I can rename it to: shouldWorkWithERC721Holder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the tests in some more detail: we're already testing that safeTransferFrom
in the describe('via safeTransferFrom')
block, what we need to test is that the ERC721Holder works with a compliant ERC721 token (i.e. it returns the correct value). Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. But I think that the best way to test that the correct value is returned from the Holder contract is to check that safeTransferFrom succeeds. Just calling onReceived directly and verifying that a magic value is returned is too low level, IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point was that it's not a token test, but a holder test - it belongs in a separate test file π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds right. I am just wondering if I should keep this style of tests/behavior, even if it's only one simple test.
@nventuro one more time, please. |
* Add the missing test for ERC721Holder * fix lint * Move the holder test to a separate file (cherry picked from commit 396680b)
This is one step towards #1147
π Description
Add test coverage for ERC721Holder.
npm run lint:all:fix
).