I successfully ran my truffle test with 1 contract passing while two failed for reasons that do not make sense to me right now.
I wrote a smart contract that “complies with ERC721 & ERC4907 standards” (NFT renting) & the two that failed are suppose to:
- “should not set UserInfo if not owner.”
- ”should return the correct UserInfo”
These are the errors that’s occurring:
Contract: RentablePets ✔ should support the ERC721 and ERC4907 standards (151ms) 1) should not set UserInfo if not the owner
Events emitted during test:
---------------------------
IERC721.Transfer(
from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
to: <indexed> 0x789d525ABeEC5574bbedB70aD2ABaac6Ed7513Bb (type: address),
tokenId: <indexed> 1 (type: uint256)
)
---------------------------
2) should return the correct UserInfo
Events emitted during test:
---------------------------
IERC721.Transfer(
from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
to: <indexed> 0x789d525ABeEC5574bbedB70aD2ABaac6Ed7513Bb (type: address),
tokenId: <indexed> 2 (type: uint256)
)
IERC721.Transfer(
from: <indexed> 0x0000000000000000000000000000000000000000 (type: address),
to: <indexed> 0x789d525ABeEC5574bbedB70aD2ABaac6Ed7513Bb (type: address),
tokenId: <indexed> 3 (type: uint256)
)
IERC4907.UpdateUser(
tokenId: <indexed> 2 (type: uint256),
user: <indexed> 0x33f1E2280D313ccAAC2Ea7D0cBd4994D1a9B99Da (type: address),
expires: 1660252958 (type: uint64)
)
IERC4907.UpdateUser(
tokenId: <indexed> 3 (type: uint256),
user: <indexed> 0xF862B034cb81e0b0bd75B88A6570D9A477B4111c (type: address),
expires: 4121727755 (type: uint64)
)
---------------------------
1 passing (4s) 2 failing
Contract: RentablePets should not set UserInfo if not the owner:
Wrong kind of exception received
- expected - actual
-ERC721: transfer caller is not approved +ERC721: transfer caller is not owner nor approved
at expectException (node_modules/@openzeppelin/test-helpers/src/expectRevert.js:20:30) at expectRevert (node_modules/@openzeppelin/test-helpers/src/expectRevert.js:75:3) at Context. (test/rentable_pets.js:26:5)
Contract: RentablePets should return the correct UserInfo: ReferenceError: unexpiredNFTUser is not defined at Context. (test/rentable_pets.js:50:18) at processTicksAndRejections (node:internal/process/task_queues:96:5)
(base) mariamstar1@mariams-MacBook-Pro rentable-NFTs %