PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

getting error when testing hardhat fundMe constructor testing #95

Closed oxd3v closed 1 year ago

oxd3v commented 1 year ago

code in test folder


        // const accounts = await ethers.getSigners()
        // deployer = accounts[0]
       const deployer = (await getNamedAccounts()).deployer
        await deployments.fixture(["all"])
        fundMe = await ethers.getContract("FundMe", deployer)
        mockV3Aggregator = await ethers.getContract(
            "MockV3Aggregator",
            deployer
        )
    })
    describe("constructor", function () {
        it("sets the aggregator addresses correctly", async () => {
            const response = await fundMe.getPriceFeed()
            assert.equal(response, mockV3Aggregator.address)
        })
    })```

getting error
```  fundMe       
    constructor

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

  0 passing (5s)
  1 failing

  1) fundMe
       "before each" hook for "sets the aggregator addresses correctly":
     ERROR processing C:\Users\mdist\hh-fcc-fundme\deploy\sample.js:
TypeError: fundMe.priceFeed is not a functionhave ```

anyone have idea?
dumindapium commented 1 year ago

code in test folder

        // const accounts = await ethers.getSigners()
        // deployer = accounts[0]
       const deployer = (await getNamedAccounts()).deployer
        await deployments.fixture(["all"])
        fundMe = await ethers.getContract("FundMe", deployer)
        mockV3Aggregator = await ethers.getContract(
            "MockV3Aggregator",
            deployer
        )
    })
    describe("constructor", function () {
        it("sets the aggregator addresses correctly", async () => {
            const response = await fundMe.getPriceFeed()
            assert.equal(response, mockV3Aggregator.address)
        })
    })```

getting error
```  fundMe       
    constructor

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

  0 passing (5s)
  1 failing

  1) fundMe
       "before each" hook for "sets the aggregator addresses correctly":
     ERROR processing C:\Users\mdist\hh-fcc-fundme\deploy\sample.js:
TypeError: fundMe.priceFeed is not a functionhave ```

anyone have idea?

Hi Md-Istiak, I got the same issue here. using this await fundMe.priceFeed(); solved the issue.

oxd3v commented 1 year ago

i had solve it .there was a mistrake in fund.sol file. thank you