You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
beforeEach(async function(){
accounts = await ethers.getSigners()
deployer = accounts[0]
await deployments.fixture(["mocks", "randomIpfs"])
randomIpfsNft = await ethers.getContract("RandomIpfsNft")
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
})
describe("constructor",() =>{
it("sets the initial value correctly", async function(){
const dogTokenUriZero = await randomIpfsNft.getDogTokenUri(0)
const isInitialized = await randomIpfsNft.getInitialized()
assert(dogTokenUriZero.includes("ipfs://"))
assert.equal(isInitialized, true)
})
})
describe("requestNft",()=> {
it("fails if payment is not enough", async () =>{
await expect(randomIpfsNft.requestNft()).to.be.revertedWith("RandomIpfsNft__NeedMoreEth")
})
it("should revert an error if payment amount is less than mint fee", async () =>{
const fee = await randomIpfsNft.getMintFee()
await expect(randomIpfsNft.requestNft({
value:fee.sub(ethers.utils.parseEther("0.001")),}).to.be.revertedWith("RandomIpfsNft__NeedMoreEth"))
})
it("emits an nftRequested events",async () =>{
const fee = await randomIpfsNft.getMintFee()
await expect(randomIpfsNft.requestNft({value:fee.toString()})).to.emit(randomIpfsNft,"NftRequested")
})
})
describe("fulfillRandomWords", async () =>{
})
describe("getBreedFromModdedRng", async () =>{
it("should return pug if the moddedRng is less than 10", async () =>{
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(7)
assert.equal(0, expectedValue)
})
it("should return shiba-INU if the moddedRng value is more than 10 but less than 40", async () =>{
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(21)
assert.equal(1, expectedValue)
})
it("should return st.bernard if moddedRng value is more than 40 but less than 100", async () =>{
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(77)
assert.equal(2, expectedValue)
})
it("should revert back an error if moddedRng value exceed 100", async () =>{
await expect(randomIpfsNft.getBreedFromModdedRng(100)).to.be.revertedWith("RandomIpfsNft__RangeOutOfBounds")
})
})
})
firstly, i do not know where i am going wrong but half of these tests are not working
secondly, i cannot figure out how to write "fulfillRandomWords" tests and i am unable to understand patrick's solution
thirdly, why are we putting these numbers
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(7)
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(21)
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(77)
how are we getting these??? can someone please explain
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
here is my randomIpfsNft.test.js
const {developmentChains, networkConfig} = require("../../helper-hardhat-config")
const {getNamedAccounts, deployments, ethers} = require("hardhat")
const {assert, expect} = require("chai")
!developmentChains.includes(network.name)?describe.skip:describe("randomIpfs NFT test", function(){
let randomIpfsNft, deployer, vrfCoordinatorV2Mock
const chainId = network.config.chainId
beforeEach(async function(){
accounts = await ethers.getSigners()
deployer = accounts[0]
await deployments.fixture(["mocks", "randomIpfs"])
randomIpfsNft = await ethers.getContract("RandomIpfsNft")
vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
})
describe("constructor",() =>{
it("sets the initial value correctly", async function(){
const dogTokenUriZero = await randomIpfsNft.getDogTokenUri(0)
const isInitialized = await randomIpfsNft.getInitialized()
assert(dogTokenUriZero.includes("ipfs://"))
assert.equal(isInitialized, true)
})
})
describe("requestNft",()=> {
it("fails if payment is not enough", async () =>{
await expect(randomIpfsNft.requestNft()).to.be.revertedWith("RandomIpfsNft__NeedMoreEth")
})
it("should revert an error if payment amount is less than mint fee", async () =>{
const fee = await randomIpfsNft.getMintFee()
await expect(randomIpfsNft.requestNft({
value:fee.sub(ethers.utils.parseEther("0.001")),}).to.be.revertedWith("RandomIpfsNft__NeedMoreEth"))
})
it("emits an nftRequested events",async () =>{
const fee = await randomIpfsNft.getMintFee()
await expect(randomIpfsNft.requestNft({value:fee.toString()})).to.emit(randomIpfsNft,"NftRequested")
})
})
describe("fulfillRandomWords", async () =>{
})
describe("getBreedFromModdedRng", async () =>{
it("should return pug if the moddedRng is less than 10", async () =>{
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(7)
assert.equal(0, expectedValue)
})
it("should return shiba-INU if the moddedRng value is more than 10 but less than 40", async () =>{
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(21)
assert.equal(1, expectedValue)
})
it("should return st.bernard if moddedRng value is more than 40 but less than 100", async () =>{
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(77)
assert.equal(2, expectedValue)
})
it("should revert back an error if moddedRng value exceed 100", async () =>{
await expect(randomIpfsNft.getBreedFromModdedRng(100)).to.be.revertedWith("RandomIpfsNft__RangeOutOfBounds")
})
})
})
firstly, i do not know where i am going wrong but half of these tests are not working
secondly, i cannot figure out how to write "fulfillRandomWords" tests and i am unable to understand patrick's solution
thirdly, why are we putting these numbers
const expectedValue = await randomIpfsNft.getBreedFromModdedRng(7)
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(21)
const expectedValue = await randomIpfsNft. getBreedFromModdedRng(77)
how are we getting these??? can someone please explain
Beta Was this translation helpful? Give feedback.
All reactions