Cyfrin / foundry-full-course-cu

GNU General Public License v3.0
3.7k stars 916 forks source link

`testPriceFeedVersionIsAccurate` should be updated after we refactored with the helper config #2896

Closed SquilliamX closed 11 hours ago

SquilliamX commented 4 days ago

Section

Section 7 | Foundry Fund Me

Could you please leave a link to the Cyfrin Updraft Lesson (or YouTube video timestamp) where this error occurs? (You can right click a video and "copy video URL at current time")

I can't copy the video url timestamp but its from Episode 11 of Foundry FundMe: from 12:00 to 12:11, after we finished refactoring.

The link is https://updraft.cyfrin.io/courses/foundry/foundry-fund-me/refactoring-helper

Operating System

Linux

Describe the bug

In episode 11 of Foundry FundMe, "Deploy a Mock PriceFeed" @ 12:11 , we run forge test --fork -url $MAINNET_RPC_URL and all the tests pass in the video but not for users following. This is outdated as this test function is asserting that the mainnet pricefeed version == 4. This is no longer correct. Chainlink updated the pricefeed verisons, so while the eth/usd sepolia pricefeed version is still 4, Chainlink's eth/usd mainnet priceFeed version is now 6. So the test testPriceFeedVersionIsAccurate should be changed to the following:

  function testPriceFeedVersionIsAccurate() public {
        if (block.chainid == 11155111) {
            uint256 version = fundMe.getVersion();
            assertEq(version, 4);
        } else if (block.chainid == 1) {
            uint256 version = fundMe.getVersion();
            assertEq(version, 6);
        }
  }       

This way if you run forge test --mt testPriceFeedVersionIsAccurate -vvvv --fork-url $SEPOLIA_RPC_URL or forge test --mt testPriceFeedVersionIsAccurate -vvvv --fork-url $MAINNET_RPC_URL the test will always pass.

Equious commented 11 hours ago

We've submitted an update to this course detailing this change. Thanks for the contribution!