Error: No deployment found for: MockV3Aggregator #2983
-
Hello guys, i am getting the error: Here is my deploy script: const { networkConfig, developmentChains } = require("../helper-hardhat-config")
const { network } = require("hardhat")
const { verify } = require("../utils/verify")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
// const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
let ethUsdPriceFeedAddress
if (developmentChains.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
const args = [ethUsdPriceFeedAddress]
const fundMe = await deploy("FundMe", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, args)
}
log("------------------------------------------------------------------")
}
module.exports.tags = ["all", "fundMe"] Also, here is my unit test code, I get the error whenever i run the const { assert } = require("chai")
const { deployments, ethers, getNamedAccounts } = require("hardhat")
describe("FundMe", async function () {
let fundMe
let deployer
let mockV3Aggregator
beforeEach(async function () {
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("sets the aggregator addresses correctly", async function () {
const response = await fundMe.priceFeed()
assert.equal(response, mockV3Aggregator.address)
})
})
}) Please I need help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@blaynejosh : Change this line in your deploy script, From this : To this : And also, Import And for testing run this command : Let me know, If it resolves your issue! If it didn't resolve your issue,
|
Beta Was this translation helpful? Give feedback.
@blaynejosh : Change this line in your deploy script,
From this :
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
To this :
const ethUsdAggregator = await ethers.getContract("MockV3Aggregator")
And also, Import
ethers
from hardhat on top!And for testing run this command :
yarn hardhat test
Let me know, If it resolves your issue!
If it didn't resolve your issue,