PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

Error! while testing fundMe fund #38

Closed ChiragG2101 closed 2 years ago

ChiragG2101 commented 2 years ago

Error:

  1) FundMe
       fund
         Updated the amount funded data structure:
     Error: VM Exception while processing transaction: reverted with reason string 'Didn't send enough!'

The code used:

const { deployments, ethers, getNamedAccounts } = require("hardhat")
const { assert, expect } = require("chai")

describe("FundMe", async function() {
    let fundMe
    let deployer
    let mockV3Aggregator
    const sendValue = ethers.utils.parseEther("1")   //1 ETH
    beforeEach(async function() {
        // const accounts = await ethers.getSigners()
        // const accountZero = accounts(0)
        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)
        })
    })
    describe("fund",async function(){
        it("Fails if you don't send enough ETH", async function(){
            await expect(fundMe.fund()).to.be.reverted
        })
        it("Updated the amount funded data structure", async function(){
            await fundMe.fund({value: sendValue})
            const response = await fundMe.addressToAmountFunded(deployer)
            assert.equal(response.toString(), sendValue.toString())
        })
    })
})
PatrickAlphaC commented 2 years ago

Can you ask in the full repo? Thanks! https://github.com/smartcontractkit/full-blockchain-solidity-course-js/