Replies: 1 comment
-
Hello @coderharsx1122 Your tokenId is just undefined... In your // Change const to let (you will be able to override this)
let tokenId = 0
// Add following in beforeEach
beforeEach(async () => {
tokenId = 0
}) Your new code should look like this: const { network, ethers, deployments, getNamedAccounts } = require("hardhat")
const { developmentChains } = require("../../helper-hardhat-config")
const { assert } = require("chai")
!developmentChains.includes(network.name)
? describe.skip
: describe("nftMarketPlace", () => {
let nftMarketPlace, deployer, player, basicNft
const price = ethers.utils.parseEther("0.1")
let tokenId = 0
beforeEach(async () => {
accounts = await ethers.getSigners()
deployer = accounts[0]
player = accounts[1]
tokenId = 0
await deployments.fixture["all"]
nftMarketPlace = await ethers.getContractAt("NftMarketPlace", "0x5FbDB2315678afecb367f032d93F642f64180aa3", deployer)
basicNft = await ethers.getContractAt("BasicNft", "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", deployer)
await basicNft.mintNft()
await basicNft.approve(nftMarketPlace.address, tokenId)
})
it("List NFT", async () => {
await nftMarketPlace.listItem(basicNft.address, tokenId, price)
const connectPlayerNftMarketPlace = nftMarketPlace.connect(player)
await connectPlayerNftMarketPlace.buyItem(basicNft.address, tokenId, {
value: price,
})
const newOwner = await basicNft.ownerOf(tokenId)
const deployerProcceds = await nftMarketPlace.getProceeds(deployer)
assert(newOwner.toString() == player)
assert(deployerProcceds.toString() == price.toString())
})
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Getting error while testing my contracts (When calling the ownerOf function)
Error ->
Error: call revert exception (method="ownerOf(uint256)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.4.0)
Test file ->
nftMarketPlace.test.js
NftMarketPlace.sol file
BasicNft.sol File
Deploy scripts
1 -> NftMarketPlace
2 -> BasicNft
Beta Was this translation helpful? Give feedback.
All reactions