smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.25k stars 2.94k forks source link

Error: VM Exception while processing transaction: reverted with reason string 'You need to spend more ETH!' #3644

Open michaelclubman515 opened 1 year ago

michaelclubman515 commented 1 year ago

Lesson

Lesson 7

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=41004

Operating System

macOS (Apple Silicon)

Describe the bug

At the unit testing section on course Lesson7 around 11:23 (https://youtu.be/gyMwXuJrbJQ?t=41004) around 11:20 failed the test "updated the amount funded data structure". Seems like sendValue failed but I declared the sendValue for 1 Ether and pass the args of sendvalue.

Error Information

FundMe
fund
updated the amount funded data structure:
Error: VM Exception while processing transaction: reverted with reason string 'You need to spend more ETH!'
at FundMe.fund (contracts/FundMe.sol:40)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)

test script - fundme.test.js


const sendValue = ethers.utils.parseEther("1")

describe("fund", async function () {
    it("Fails if you don't send enough ETH", async function () {
        await expect(fundMe.fund()).to.be.revertedWith(
            "You need to spend more ETH!"
        )
    })

    it("updated the amount funded data structure", async function () {
        // 执行fund,获取funder的地址=>金额映射,和fund的金额做对比
        await fundMe.fund({ value: sendValue })
        const response = await fundMe.addressToAmountFunded(deployer)
        assert.equal(response.toString(), sendValue.toString())
    })