Open bestinbabu opened 11 months ago
const { deployments, ethers, getNamedAccounts } = require("hardhat")
const { assert, expect } = require("chai")
const { developmentChains } = require("../../helper-hardhat-config")
describe("FundMe", function () {
let fundMe
let mockV3Aggregator
let deployer
beforeEach(async () => {
// const accounts = await ethers.getSigners()
// deployer = accounts[0]
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)
})
})
})
this is my code and it's note working too, this is the following error when i run 'yarn hardhat test':
Compiled 1 Solidity file successfully
FundMe
constructor
1) sets the aggregator addresses correctly
0 passing (1s)
1 failing
1) FundMe
constructor
sets the aggregator addresses correctly:
TypeError: no matching function (argument="key", value="getPriceFeed", code=INVALID_ARGUMENT, version=6.6.4)
at makeError (node_modules/ethers/src.ts/utils/errors.ts:670:21)
at assert (node_modules/ethers/src.ts/utils/errors.ts:694:25)
at assertArgument (node_modules/ethers/src.ts/utils/errors.ts:706:5)
at Interface.getFunctionName (node_modules/ethers/src.ts/abi/interface.ts:542:23)
at buildWrappedMethod (node_modules/ethers/src.ts/contract/contract.ts:334:34)
at Contract.getFunction (node_modules/ethers/src.ts/contract/contract.ts:859:22)
at Object.get (node_modules/ethers/src.ts/contract/contract.ts:757:39)
at Context.<anonymous> (test/unit/FundMe.test.js:23:43)
error Command failed with exit code 1.
it was supossed to work, since i already have check every line of code and it's the same from the tutorial. the video link in the part of the code i'm in https://youtu.be/gyMwXuJrbJQ?t=40700
Navigate to the GitHub repository at https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/blob/main. Find the hardhat.config.js file, copy its requires, and then replace the corresponding sections in your local hardhat.config.js file.
In the same GitHub repository, locate the package.json file, copy its contents, and replace the content in your local package.json file.
After updating your configuration and package files, you should delete your local node_modules directory to remove potentially conflicting dependencies.
npm i --force
The problem i've been experiencing appears to be related to dependency conflicts. Following these steps should help resolve the issue.
Remember to follow all the instructions in the specified order. If you encounter any problems, please don't hesitate to ask for assistance.
Hello i noticd using .target dets the address of the contract, while .address gets the adrress where the code is been deployed. You can try the following below
describe("constructor", async function () {
it("sets the aggregator addresses correctly", async () => {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.target)
})
})
no matching function (argument="key", value="priceFeed", code=INVALID_ARGUMENT, version=6.6.4)
` describe('FundMe', async () => { let fundMe let MockV3Aggregator
beforeEach(async () => { const { deployer } = await getNamedAccounts() // get deployer account await deployments.fixture(['all']) // deploy all contracts with all tag fundMe = await ethers.getContract('FundMe', deployer,90) // Get the 'FundMe' contract instance with the 'deployer' address MockV3Aggregator = await ethers.getContractAt('MockV3Aggregator', deployer) // Get the 'MockV3Aggregator' contract instance with the 'deployer' address }) describe('constructor', () => { it('sets the aggregator address', async () => { const response = await fundMe.priceFeed() assert.equal(response, MockV3Aggregator) }) }) }) `