Skip to content

How to access the data stored in events and public variables while testing #2113

Answered by alymurtazamemon
sadath-12 asked this question in Q&A
Discussion options

You must be logged in to vote

@sadath-12 Here are my test for requestNFT and fulfillRandomWords functions. It covers all lines you can check with coverage tool, but if you are more specifically wants to write test like this way then you can check the tests that we did on Lesson 9 for events. The way you are using for testing requestNFT, for that you need to wait and then check either the returned id from event is greater than 0 or not. Like this we did in lesson 9 const requestId = await txReceipt.events[1].args.requestId; , assert(requestId.toNumber() > 0);

describe("requestNFT", () => {
  it("should revert if amount is less than mintFee.", async () => {
    await expect(randomIpfsNft.requestNFT()).to.be.revertedWith(

Replies: 2 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sadath-12
Comment options

You must be logged in to vote
16 replies
@sadath-12
Comment options

@alymurtazamemon
Comment options

@sadath-12
Comment options

@alymurtazamemon
Comment options

@sadath-12
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants