繁体   English   中英

错误:处理交易时出现 VM 异常:已恢复,原因字符串为“您需要花费更多 ETH!”

[英]Error: VM Exception while processing transaction: reverted with reason string 'You need to spend more ETH!'

solidity课程Lesson7单元测试部分 11:23左右

https://youtu.be/gyMwXuJrbJQ?t=41004。未通过“更新金额数据结构”测试。 似乎 sendValue 失败了,但我声明了 1 Ether 的 sendValue 并传递了 sendvalue 的参数。

错误信息

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)

测试脚本 - 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())
    })

尝试从以下位置删除“异步”字样:

describe("fund", async function () {

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM