Lesson 14: AssertionError: expected '0' to equal '1' #850
-
@PatrickAlphaC advice us to write our own test for Here is the code for both lessons. describe("fulfillRandomWords", () => {
it("mints NFT after random number is returned", async function () {
await new Promise(async (resolve, reject) => {
randomIpfsNft.once("NftMinted", async () => {
try {
const tokenUri = await randomIpfsNft.tokenURI("0");
const tokenCounter = await randomIpfsNft.getTokenCounter();
assert.equal(tokenUri.toString().includes("ipfs://"), true);
assert.equal(tokenCounter.toString(), "1");
resolve();
} catch (e) {
console.log(e);
reject(e);
}
});
try {
const fee = await randomIpfsNft.getMintFee();
const requestNftResponse = await randomIpfsNft.requestNft({
value: fee.toString(),
});
const requestNftReceipt = await requestNftResponse.wait(1);
await vrfCoordinatorV2Mock.fulfillRandomWords(
requestNftReceipt.events[1].args.requestId,
randomIpfsNft.address
);
} catch (e) {
console.log(e);
reject(e);
}
});
});
}); ------------------------------And this--------------------------- it("Allows users to mint an NFT, and updates appropriately", async function () {
const txResponse = await basicNft.mintNft();
await txResponse.wait(1);
const tokenURI = await basicNft.tokenURI(0);
const tokenCounter = await basicNft.getTokenCounter();
assert.equal(tokenCounter.toString(), "1");
assert.equal(tokenURI, await basicNft.TOKEN_URI());
}); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
it fixed after i change at contract |
Beta Was this translation helpful? Give feedback.
it fixed after i change at contract
s_tokenCounter += s_tokenCounter;
tos_tokenCounter = s_tokenCounter + 1;