Replies: 3 comments 10 replies
-
Hello @AnaAse, Your assertion is wrong, so the best thing to do is use |
Beta Was this translation helpful? Give feedback.
-
Anas-Laptop:foundry-fund-me-f23 ana$ forge snapshot -vvvv Ran 10 tests for test/FundMetest.t.sol:FundMeTest [PASS] testFundFailsWithoutEnoughETH() (gas: 23029) [PASS] testFundUpdatesFundedDataStructure() (gas: 99815) [PASS] testMinimumDollarFive() (gas: 8499) [PASS] testOnlyOwnerCanWithdraw() (gas: 100066) [PASS] testOwnerIsMsgSender() (gas: 8509) [PASS] testPriceFeedVersionIsAccurate() (gas: 14046) [PASS] testWithDrawWithASingleFunder() (gas: 88172) Traces: [PASS] testWithdrawFromMultipleFunders() (gas: 488496) [FAIL: panic: assertion failed (0x01)] testWithdrawFromMultipleFundersCheaper() (gas: 599132) [599132] FundMeTest::testWithdrawFromMultipleFundersCheaper() Suite result: FAILED. 9 passed; 1 failed; 0 skipped; finished in 10.75ms (7.53ms CPU time) Ran 1 test suite in 702.61ms (10.75ms CPU time): 9 tests passed, 1 failed, 0 skipped (10 total tests) Failing tests: Encountered a total of 1 failing tests, 9 tests succeeded |
Beta Was this translation helpful? Give feedback.
-
I used the console.log. but Im getting the same: Encountered a total of 1 failing tests, 9 tests succeeded function testWithdrawFromMultipleFundersCheaper() public funded {
} |
Beta Was this translation helpful? Give feedback.
-
Good day!
Nothing less than PANIC, would you please bring some light?
(I would like to send my code in a different way I´ve seen other students doing it, not copy-paste)
Failing tests:
Encountered 1 failing test in test/FundMetest.t.sol:FundMeTest
[FAIL: panic: assertion failed (0x01)] testWithdrawFromMultipleFundersCheaper() (gas: 599132)
Encountered a total of 1 failing tests, 9 tests succeeded
FundMeTest:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {Test, console} from "forge-std/Test.sol";
import {FundMe} from "../src/FundMe.sol";
import {DeployFundMe} from "../script/DeployFundMe.s.sol";
contract FundMeTest is Test {
FundMe fundMe;
address USER = makeAddr("user"); //we can use this user when we want to work with somebody
uint256 constant SEND_VALUE = 0.1 ether; // that makes it 100000000000000000
uint256 constant STARTING_BALANCE = 10 ether;
uint256 constant GAS_PRICE = 1;
function setUp() external {
// fundMe = new FundMe(0x106379F11C3cF4027C38655b79327081eA9C9Cf5); OJO este numero copiado del curso!!!
DeployFundMe deployFundMe = new DeployFundMe();
fundMe = deployFundMe.run();
vm.deal(USER, 100e18);
}
function testMinimumDollarFive() public view {
assertEq(fundMe.MINIMUM_USD(), 5e18);
}
function testOwnerIsMsgSender() public view {
assertEq(fundMe.getOwner(), msg.sender);
// reset everything every simgle time as it will run SetUp and then the function, again SetUp and the other function
function testAddsFunderToArrayOfFunders() public{
vm.prank(USER);
fundMe.fund{value: SEND_VALUE}();
modifier funded() {
vm.prank(USER);
fundMe.fund{value: SEND_VALUE}();
_;
}
// any test we write after the above modifier, if we add the funded
function testOnlyOwnerCanWithdraw() public funded{ //this funded comes from the modifier to avoid repeating code
vm.prank(USER);
vm.expectRevert();
fundMe.withdraw();
}
}
FundMe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
// Note: The AggregatorV3Interface might be at a different location than what was in the video!
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
import {PriceConverter} from "./PriceConverter.sol";
error FundMe__NotOwner();
contract FundMe {
using PriceConverter for uint256;
}
}
// Concepts we didn't cover yet (will cover in later sections)
// 1. Enum
// 2. Events
// 3. Try / Catch
// 4. Function Selector
// 5. abi.encode / decode
// 6. Hash with keccak256
// 7. Yul / Assembly
Beta Was this translation helpful? Give feedback.
All reactions