PatrickAlphaC / hardhat-fund-me-fcc

82 stars 182 forks source link

Error: No Contract deployed with name FundMe #155

Closed Crawlling closed 1 year ago

Crawlling commented 1 year ago

Hi,I encountered a problem in the test Here is my code.

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

describe("FundMe", async function () { let fundme let deployer let MockV3Aggregator

beforeEach(async () => {
    deployer = (await getNamedAccounts()).deployer
    await deployments.fixture(["all"])
    fundme = await ethers.getContract("FundMe", deployer)
    MockV3Aggregator = await ethers.getContract(
        "MockV3Aggregator",
        deployer
    )
})

describe("constructor", async function () {
    it("set the aggregator addresses correctly", async function () {
        const response = await fundme.priceFeed()

        assert.equal(response, MockV3Aggregator.address)
    })
})

})

Here is error: FundMe constructor 1) "before each" hook for "set the aggregator addresses correctly"

0 passing (574ms) 1 failing

1) FundMe "before each" hook for "set 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:95:5) at Context. (test/unit/FundMe.test.js:12:18)

I already change ethers version to 5,the error from “JsonRpc。。。” to this.

Thank u for your time.

isosatya commented 1 year ago

ethers.getContract() is just not being found as function of ethers for me. I am trying to use ethers.getContractAt as here, but it is just not deploying the FundMe.

fundMe = await ethers.getContractAt("FundMe", deployer);

mockV3Aggregator at least seems to be working. But I am super stuck with fundMe

 mockV3Aggregator = await ethers.getContractAt(
            "MockV3Aggregator",
            deployer
        );

When trying to do the test I get the following error:

1) FundMe
       constructor
         sets the aggregator address correctly:
     Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="priceFeed()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)

My deployings seem to work fine though. But for the testing it is just not deploying.

isosatya commented 1 year ago

Hope @PatrickAlphaC gets to see this :D

PatrickAlphaC commented 1 year ago

Hi all! Thanks for pinging me. Could you please do the following:

  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

Thank you!