javascriptethereumsoliditychainlinkchainlink-keepers

TypeError: Cannot read properties of undefined (checkUpkeep, chainlink keepers)


I'm getting this error while testing my smart contract using hardhat

TypeError: Cannot read properties of undefined (reading 'checkUpkeep')

code for the test

 describe("checkUpkeep", () => {
              it("returns false if people haven't sent any eth", async () => {
                  await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
                  await network.provider.send("evm_mine", [])
                  const { upkeepNeeded } = await raffle.callstatic.checkUpkeep("0x")
                  assert(!upkeepNeeded)
              })
          })

relevant code of the smart contract

function checkUpkeep(
        bytes memory /* checkData*/
    )
        public
        view
        override
        returns (
            bool upkeepNeeded,
            bytes memory /* performData */
        )
    {
        bool isOpen = RaffleState.OPEN == s_raffleState;
        bool timePassed = (((block.timestamp) - s_lastTimeStamp) > i_interval);
        bool hasPlayers = s_players.length > 0;
        bool hasBalance = address(this).balance > 0;
        upkeepNeeded = (isOpen && timePassed && hasPlayers && hasBalance);
        return (upkeepNeeded, "0x0");
    }

Solution

  • I know it's too late, but when you try to call the checkUpkeep function, it should be "callStatic" not "callstatic"