Closed eugenekhoo1 closed 1 year ago
@eugenekhoo1 Please share the test.
I had to use 'requesId' instead to get the arguments out in this test
describe("RandomNFT Unit Tests", function () {
let randomNft, deployer, vrfCoordinatorV2Mock
beforeEach(async function () {
accounts = await ethers.getSigners()
deployer = accounts[0]
await deployments.fixture(["mocks", "randomnft"])
randomNft = await ethers.getContract("RandomIpfsNFT", deployer)
vrfCoordinatorV2Mock = await ethers.getContract(
"VRFCoordinatorV2Mock"
)
})
describe("fulfillRandomWords", function () {
it("mints nft after random number is returned", async function () {
await new Promise(async (resolve, reject) => {
randomNft.once("NftMinted", async function () {
console.log("Event emitted!")
// check stuff
try {
const firstTokenUri =
await randomNft.getTokenUris(0) // returns ipfs hash
const tokenCounter =
await randomNft.getTokenCounter()
assert(
firstTokenUri.toString().includes("ipfs://")
)
assert.equal(tokenCounter.toString(), "1")
resolve()
} catch (e) {
console.log(e)
reject(e)
}
})
try {
const mintFee = await randomNft.getMintFee()
const tx = await randomNft.requestNft({
value: mintFee,
})
const txReceipt = await tx.wait(1)
await vrfCoordinatorV2Mock.fulfillRandomWords(
txReceipt.events[1].args.requesId,
randomNft.address
)
} catch (e) {
console.log(e)
reject(e)
}
})
})
})
@eugenekhoo1 And what does your event look like? Can you show it? It is better if you leave your repository link so I can see all things at once.
@alymurtazamemon Ahhhh..now that you mentioned that..i see that its misspelled....my bad..thanks!
I was running test and kept encountering the error
Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.7.0)
When I console.log(txReceipt.events[1].args)..i get this output:
Is this a bug where the argument is being misspelled as requesId?? or is it likely due to errors in my code?