Lesson 7 : Error: could not decode result data (value="0x", info={ "method": "getPriceFeed", "signature": "getPriceFeed()" }, code=BAD_DATA, version=6.7.1) #6102
-
I'm getting this error while testing fundMe constructor. It's grabing contract as fundMe..I have also log it in terminal 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 function(){
//deploy fundme using hardhat deploy
// const accounts = await ethers.getSigners();//returns acounts in goerli
// const accountZero = accounts[0]
deployer = (await getNamedAccounts()).deployer
deployments.fixture(["all"])// fixture allows us run entire deploy folder
fundMe = await ethers.getContractAt("FundMe",deployer ) // to get most recent deployed contract
_mockV3Aggregator = await ethers.getContractAt("MockV3Aggregator",deployer)
console.log(fundMe)
})
describe("constructor",async function(){
it("sets the aggregator address correctly", async function(){
const response = await fundMe.getPriceFeed();
assert.equal(response,_mockV3Aggregator.address)
})
})
}) Here is my terminal output:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
try change |
Beta Was this translation helpful? Give feedback.
-
am also facing the same issue and error😪..somebody please help |
Beta Was this translation helpful? Give feedback.
-
I also have the same issue with v. 6.7.1. |
Beta Was this translation helpful? Give feedback.
-
Hey actually we need to use getContractAt() but the function definition is a bit different . Here is my FundMe.test.js snapshot for reference , you can use it this way :
|
Beta Was this translation helpful? Give feedback.
-
thanks @parthsarthimishra this works in 2024. |
Beta Was this translation helpful? Give feedback.
Hey actually we need to use getContractAt() but the function definition is a bit different . Here is my FundMe.test.js snapshot for reference , you can use it this way :