PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

WinnerPicked event is not emitting on goerli network and performUpkeep function not firing in Chainlink Automation #119

Closed wave-nature closed 1 year ago

wave-nature commented 1 year ago

I have deployed Raffle Smart Contract on goerli network, but when I am doing stage testing on goerli network is not emitting WinnerPicked event neither is showing triggering of performUpkeep function on chainlink Automation. Please Help I am stuck here!!

const { assert, expect } = require("chai")
const { getNamedAccounts, ethers, network } = require("hardhat")
const { developmentsChains } = require("../../helper-hardhat-config")

developmentsChains.includes(network.name)
    ? describe.skip
    : describe("Raffle Staging Test", function () {
          let raffle, raffleEnteranceFee, deployer

          beforeEach(async function () {
              deployer = (await getNamedAccounts()).deployer
              raffle = await ethers.getContract("Raffle", deployer)
              raffleEnteranceFee = await raffle.getEntranceFee()
          })

          describe("fulfillRandomWords", function () {
              it("works with live Chainlink Automation and Chainlink VRF, we get a random winner", async function () {
                  // enter the raffle
                  const startingTimeStamp = await raffle.getLatestTimeStamp()
                  const accounts = await ethers.getSigners()

                  console.log("setting up listner")
                  await new Promise(async (resolve, reject) => {
                      raffle.once("WinnerPicked", async function () {
                          console.log("winner picked")
                          try {
                              const recentWinner = await raffle.getRecentWinner()
                              const raffleState = await raffle.getRaffleState()
                              const winnerEndingBalance = await accounts[0].getBalance()
                              const endingTimeStatmp = await raffle.getLatestTimeStamp()

                              await expect(raffle.getPlayer(0)).to.be.reverted
                              assert.equal(recentWinner.toString(), accounts[0].address)
                              assert.equal(raffleState.toString(), "0")
                              assert.equal(
                                  winnerEndingBalance.toString(),
                                  winnerStartingBalance.add(raffleEnteranceFee).toString()
                              )
                              assert(endingTimeStatmp > startingTimeStamp)
                              resolve()
                          } catch (error) {
                              console.log(error)
                              reject(error)
                          }
                      })
                      console.log("entering raffle")
                      const tx = await raffle.enterRaffle({ value: raffleEnteranceFee })
                      await tx.wait(1)
                      console.log("time to wait")
                      const winnerStartingBalance = await accounts[0].getBalance()
                  })

                  // set up listner before we enter the raffle (just in case blockchain moves REALLY  FAST)
                  //   await raffle.enterRaffle({value:raffleEnteranceFee})
              })
          })
      })

/**
 *  1. Get our SubId for Chainlink VRF
 *  2. Deploy our contract using the subId
 *  3. Register the contract with Chainlink VRF & it's subId
 *  4. Register the contract with Chainlink Automation
 *  5. Run Sstaging tests
 */
BetterZ3 commented 1 year ago

Me too

PatrickAlphaC commented 1 year ago

Could you make this issue on the full repo? Thanks!

https://github.com/smartcontractkit/full-blockchain-solidity-course-js