PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

Getting error on Raffle staging test when deploying on goerli #113

Closed uditrajawat closed 1 year ago

uditrajawat commented 1 year ago
const { inputToConfig } = require("@ethereum-waffle/compiler");
const { assert, expect } = require("chai");
const { network, getNamedAccounts, deployments, ethers } = require("hardhat");
const { resolveConfigFile } = require("prettier");
const {
  developmentChains,
  networkConfig,
} = require("../../helper-hardhat-config");

developmentChains.includes(network.name)
  ? describe.skip
  : describe("Raffle Unit Tests", function () {
      let raffle, raffleEntranceFee, deployer;

      beforeEach(async function () {
        deployer = (await getNamedAccounts()).deployer;
        raffle = await ethers.getContract("Raffle", deployer);
        raffleEntranceFee = await raffle.getentraceFee();
      });

      describe("fulfillRandomWords", function () {
        it("works only with live chainLink Keepers and chinlink vrf,we get a random winner", async function () {
          const startingTimeStamp = await raffle.getLatestTimeStamp();
          const accounts = await ethers.getSigners();
          await new Promise(async (resolve, reject) => {
            raffle.once("Winner Picked", async function () {
              console.log("winner picked,event fired");

              try {
                const recentWinner = await raffle.getRecentWinner();
                const raffleState = await raffle.getgetRaffleState();
                const winnerEndingBalance = await accounts[0].getBalance();
                const endingTimeStamp = await raffle.getLatestTimeStamp();

                await expect(raffle.getPlayer(0)).to.be.reverted;
                assert.equal(recentWinner.toString(), accounts[0].address);
                assert.equal(raffleState, 0);
                assert.equal(
                  winnerEndingBalance.toString(),
                  winnerStartingBalance.add(raffleEntranceFee).toString()
                );
                assert(endingTimeStamp > startingTimeStamp);
                resolve();
              } catch (error) {
                console.log(error);
                reject(e);
              }
            });
            //then entering the raffle
            await raffle.raffleEntranceFee({
              value: raffleEntranceFee,
            });
            const winnerStartingBalance = await accounts[0].getBalance();
          });
        });
      });
    });

Screenshot (232)

PatrickAlphaC commented 1 year ago

Can you:

  1. Make this a discusson on the full repo? https://github.com/smartcontractkit/full-blockchain-solidity-course-js/
  2. Follow this section for formatting questions? https://www.youtube.com/watch?t=19846&v=gyMwXuJrbJQ&feature=youtu.be