PatrickAlphaC / hardhat-fund-me-fcc

83 stars 184 forks source link

Error: No Contract deployed with name FundMe #35

Closed asmar10 closed 2 years ago

asmar10 commented 2 years ago

Hi im facing this error not sure what im doing wrong this appears when i run yarn hardhat test

 FundMe
    constructor

      1) "before each" hook for "sets the aggregator addresses correctly"

  0 passing (2s)
  1 failing

  1) FundMe
       "before each" hook for "sets the aggregator addresses correctly":
     Error: No Contract deployed with name FundMe
      at Object.getContract (node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:447:11)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at runNextTicks (node:internal/process/task_queues:65:3)
      at listOnTimeout (node:internal/timers:526:9)
      at processTimers (node:internal/timers:500:7)
      at Context.<anonymous> (test\unit\Fundme.test.js:16:14)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

i don't know why it says no contract deployed even though i have deployed it. and this test code is supposed to get that deployment.

this is the part of code :

const { expect, assert } = require("chai");
const { ethers, deployments, getNamedAccounts } = require("hardhat");

describe("FundMe", async function () {

  let fundMe;
  let deployer;
  let MockV3Aggregator;
  const sendValue = ethers.utils.parseEther("1")

  beforeEach(async function () {
    deployer = (await getNamedAccounts()).deployer
    await deployments.fixture(["all"]);
    MockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer)

    fundMe = await ethers.getContract("FundMe", deployer)
  })

  describe("constructor", async function () {
    it("sets the aggregator addresses correctly", async function () {
      const response = await fundMe.priceFeed()
      assert.equal(response, MockV3Aggregator.address)
    })
  })

PS: i have made sure of the naming conventions as well the contract file name and contract name goes by FundMe.sol and FundMe

RoboCrypter commented 2 years ago

Hello friend: please edit this line: let MockV3Aggregator; to let mockV3Aggregator , because your naming convention is same as the contract "MockV3Aggregator" .

Hopefully ..It will work

PatrickAlphaC commented 2 years ago

Please ask questions in the discussions tab of the full course, thank you!

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