Closed deep0072 closed 1 year ago
Problems and bugs should be opened in the discussion part; this section is for issues in the course / repo / etc..
In any case, have you tried prompting ChatGPT or any other AI for this problem? This is the prompt I got when copied your issue to it, this might help:
If your test is failing, it's possible that the fundMe.fund()
method is not actually triggering the revert Not_Sufficient_Amount();
as expected.
There could be several reasons why your test is failing:
There is a sufficient amount of Ether: As per the condition in your contract, if msg.value.conversionRate(s_priceFeed)
is greater than or equal to MINIMUM_USD, then the contract will not revert. Please ensure that when you call fundMe.fund()
in your test, you are not sending any Ether or the conversion rate results in a value that is less than MINIMUM_USD
.
Price feed data issue: If s_priceFeed doesn't return the expected value, the condition may not evaluate as expected. Make sure the oracle data feed is providing the correct value.
Error in expectRevert usage: Ensure you're using the expectRevert correctly. The correct syntax as per OpenZeppelin test helpers is await expectRevert.unspecified(yourFunctionCall). It could look like:
await expectRevert.unspecified(fundMe.fund());
Mismatch in revert reason: If the revert reason in your test doesn't match the revert reason in your smart contract, the test will fail. If the contract code is using a custom error type like revert Not_Sufficient_Amount(); then you should specify this in your test code as follows:
await expectRevert(fundMe.fund(), "Not_Sufficient_Amount");
Without knowing more details about your fundMe.fund()
implementation and the context, it's hard to give a more accurate answer. Ensure to check the aforementioned points in order to troubleshoot the issue.
msg.value.conversionRate(s_priceFeed) here msg.value is zero then how can be it greater than zero i have used phind.com as well. but still issue not resolved
fix the issue by changing function name
function testFailWithoutEnoughEth()
to function testFundFailsWithoutEnoughETH()
but dont know why it fixed. anyone can explain
Could you please provide the whole contract with snapshot of error?. Additionally when your using
function testFundFailsWithoutEnoughETH()
i guess test is not able to find function cause solidity is case sensitive hence it is passing idk. But could you share this in Discussion tab + and provide source code?
Hi Could you help me with this
Lesson
Lesson 7
https://www.youtube.com/watch?v=sas02qSFZ74)
No response
Operating System
Windows
Describe the bug
here i am trying to run test using forge test.