smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.01k stars 2.91k forks source link

getting error while test the marketplace #5492

Closed talhaEth closed 1 year ago

talhaEth commented 1 year ago

Discussed in https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/5491

Originally posted by **talha073** May 15, 2023 I am getting this error white test the nft marketplace @alymurtazamemon ![65](https://github.com/smartcontractkit/full-blockchain-solidity-course-js/assets/66763322/cd417daf-3a78-42b2-b8d3-7630c1241927) here is the code **/*nftMarketplace.test.js*/** const { assert, expect } = require("chai") const { network, deployments, ethers, getNamedAccounts } = require("hardhat") const { developmentChains } = require("../../helper-hardhat-config") !developmentChains.includes(network.name) ? describe.skip : describe("Nft Marketplace", () => { let nftMarketplace, BasicNft, deployer, player const PRICE = ethers.utils.parseEther("0.001") const TOKEN_ID = 0 beforeEach(async function () { deployer = (await getNamedAccounts()).deployer // player = (await getNamedAccounts()).player const accounts = await ethers.getSigners() player = accounts[1] await deployments.fixture(["all"]) nftMarketplace = await ethers.getContract("NftMarketplace") BasicNft = await ethers.getContract("BasicNft") await BasicNft.mintNft() //deployer mintingh it //deployer approving to send it ot marketplace and only if approve function call then marketplace will call transferfrom on those nfts await BasicNft.approve(nftMarketplace.address, TOKEN_ID) }) it("lists and can be bought", async () => { await nftMarketplace.listItems(BasicNft.address, TOKEN_ID, PRICE) const playerConnectedNftMarketplace = nftMarketplace.connect(player) await playerConnectedNftMarketplace.buyItems(BasicNft.address, TOKEN_ID, { value: PRICE, }) const newOwner = await BasicNft.ownerOf(TOKEN_ID) const deployerProceeds = await nftMarketplace.getProceeds(deployer) assert(newOwner.toString(), player.address) assert(deployerProceeds.toString(), PRICE.toString()) }) })
alymurtazamemon commented 1 year ago

@talha073 I have answered your query in the discussions and because it is your personal code-related issue and not course-related due to that I am closing this issue.

Check the answer in the discussion.

closing #5492