I've been trying to get this test to work since a long time, out of 8 this is the only one that fails, am not able to understand what goes wrong even by using the more verbose test promt (-vvvv)
test code:
function testCanBuyListing() public {
uint256 userBalance = address(this).balance;
nft.transferFrom(address(this), user, nftId);
uint256 listingId = opensea.list(nft, nftId, 1 ether);
vm.prank(user);
opensea.buyListing{value: 1 ether}(listingId);
}
error (along with traces)
[141591] OpenseaTest::testCanBuyListing()
├─ [32624] TestNFT::transferFrom(OpenseaTest: [0xb4c79dab8f259c7aee6e5b2aa729821864227e84], 0x0000000000000000000000000000000000000001, 1)
│ ├─ emit Transfer(from: OpenseaTest: [0xb4c79dab8f259c7aee6e5b2aa729821864227e84], to: 0x0000000000000000000000000000000000000001, id: 1)
│ └─ ← ()
├─ [94435] Opensea::list(TestNFT: [0x185a4dc360ce69bdccee33b3784b0282f7961aea], 1, 1000000000000000000)
│ ├─ emit NewListing(listing: (0x185a4dc360ce69bdccee33b3784b0282f7961aea, 1, 0xb4c79dab8f259c7aee6e5b2aa729821864227e84, 1000000000000000000))
│ ├─ [842] TestNFT::transferFrom(OpenseaTest: [0xb4c79dab8f259c7aee6e5b2aa729821864227e84], Opensea: [0xce71065d4017f316ec606fe4422e11eb2c47c246], 1)
│ │ └─ ← "WRONG_FROM"
│ └─ ← "WRONG_FROM"
└─ ← "WRONG_FROM"
Best Answer
Error might be from either
address(this)
anduser
is the same address oraddress(this)
might have no nft