Replies: 1 comment
-
when you use revertedWith() you need to make sure that the msg matches the message to the one in FundMe.sol so you should match the message in these parts of code function fund() public payable {
require(
msg.value.getConversionRate(priceFeed) >= MIN_ACCEPTABLE_VALUE,
"You need to spend more ETH!"
);
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} await expect(fundMe.fund()).to.be.revertedWith('You need to spend more ETH!'); and alternatively await expect(fundMe.fund()).to.be.reverted you can opt for any one way |
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.
-
While writing the unit test for
fund()
, the function is expected to fail due to having sent less ETH than expected. However, when I write the test to handle the function being reverted, it fails with the following error:the test:
If I write the line as
await fundMe.fund()
, the test passes.Beta Was this translation helpful? Give feedback.
All reactions