getting error in all the tests of fundme #6414
khushbusandhu
started this conversation in
General
Replies: 1 comment
-
|
Error: could not decode result data (value="0x", info={ "method": "getAddressToAmountFunded", "signature": "getAddressToAmountFunded(address)" }, code=BAD_DATA, version=6.10.0) if you find the solution plz let me know |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
this is my unit test code
const { deployments, ethers, getNamedAccounts } = require("hardhat"); const { assert, expect } = require("chai"); require("@nomiclabs/hardhat-ethers"); const { developmentChains } = require("../../helper-hardhat-config"); describe("FundMe", async function () { let fundMe; let deployer; let mockV3Aggregator; const sendValue = ethers.parseEther("1"); beforeEach(async function () { deployer = (await getNamedAccounts()).deployer; await deployments.fixture(["all"]); fundMe = await ethers.getContractAt("FundMe", deployer); mockV3Aggregator = await ethers.getContractAt("MockV3Aggregator", deployer); }); describe("constructor", function () { it("sets the aggregator addresses correctly", async () => { const response = await fundMe.target; assert.equal(response, mockV3Aggregator.target); }); }); describe("fundme", function () { it("Fails if you don't send enough ETH", async () => { await expect(fundMe.fund()).to.be.revertedWith( "You need to spend more ETH!" ); }); it("Updates the amount funded data structure", async () => { await fundMe.fund({ value: sendValue }); const response = await fundMe.getAddressToAmountFunded(deployer); assert.equal(response.toString(), sendValue.toString()); }); it("Adds funder to funders array", async () => { await fundMe.fund({ value: sendValue }); const funder = await fundMe.getFunder(0); assert.equal(funder, deployer); }); }); describe("withdraw", function () { beforeEach(async () => { await fundMe.fund({ value: sendValue }); }); it("withdraws ETH from a single funder", async () => { // Arrange const startingFundMeBalance = await ethers.provider.getBalance( fundMe.target ); console.log(startingFundMeBalance); const startingDeployerBalance = await ethers.provider.getBalance( deployer ); console.log(startingDeployerBalance); // Act const transactionResponse = await fundMe.withdraw(); const transactionReceipt = await transactionResponse.wait(1); console.log(transactionReceipt); const { gasUsed, gasPrice } = transactionReceipt; const gasCost = gasUsed * gasPrice; const endingFundMeBalance = await ethers.provider.getBalance( fundMe.target ); console.log(endingFundMeBalance); const endingDeployerBalance = await ethers.provider.getBalance(deployer); console.log(endingDeployerBalance); // Assert // Maybe clean up to understand the testing assert.equal(endingFundMeBalance, 0); assert.equal( startingFundMeBalance + startingDeployerBalance, endingDeployerBalance + gasCost ); }); }); });and this is my terminal output
please help me with this
Beta Was this translation helpful? Give feedback.
All reactions