-
-
Save dabit3/8d41d27c60b4f16b105bd2479013c172 to your computer and use it in GitHub Desktop.
NFTMarketplace V2 Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* test/sample-test.js */ | |
describe("NFTMarket", function() { | |
it("Should create and execute market sales", async function() { | |
/* deploy the marketplace */ | |
const NFTMarketplace = await ethers.getContractFactory("NFTMarketplace") | |
const nftMarketplace = await NFTMarketplace.deploy() | |
await nftMarketplace.deployed() | |
let listingPrice = await nftMarketplace.getListingPrice() | |
listingPrice = listingPrice.toString() | |
const auctionPrice = ethers.utils.parseUnits('1', 'ether') | |
/* create two tokens */ | |
await nftMarketplace.createToken("https://www.mytokenlocation.com", auctionPrice, { value: listingPrice }) | |
await nftMarketplace.createToken("https://www.mytokenlocation2.com", auctionPrice, { value: listingPrice }) | |
const [_, buyerAddress] = await ethers.getSigners() | |
/* execute sale of token to another user */ | |
await nftMarketplace.connect(buyerAddress).createMarketSale(1, { value: auctionPrice }) | |
/* resell a token */ | |
await nftMarketplace.connect(buyerAddress).resellToken(1, auctionPrice, { value: listingPrice }) | |
/* query for and return the unsold items */ | |
items = await nftMarketplace.fetchMarketItems() | |
items = await Promise.all(items.map(async i => { | |
const tokenUri = await nftMarketplace.tokenURI(i.tokenId) | |
let item = { | |
price: i.price.toString(), | |
tokenId: i.tokenId.toString(), | |
seller: i.seller, | |
owner: i.owner, | |
tokenUri | |
} | |
return item | |
})) | |
console.log('items: ', items) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, Nadir there's been an issue in the code
It gives me this error on running the command
Please look into the matter and reply fast.