Reputation: 343
At the unit testing section on solidity course Lesson7 around 11:23
https://youtu.be/gyMwXuJrbJQ?t=41004。 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())
})
Upvotes: 0
Views: 266
Reputation: 86
try to remove the "async" word from:
describe("fund", async function () {
Upvotes: 0