Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced-foundry: Section 3 - DeFi Protocoll video 18 - DSCE advanced testing | Written lesson content does not match to video content #361

Open
MrRobWeb opened this issue Feb 20, 2025 · 4 comments

Comments

@MrRobWeb
Copy link
Contributor

Even though I celebrate the content of written lesson about the different layers of testing it doesn't match to the video content. Unfortunately, I haven't found the video for "Leveling up testing". I would really appreciate a video about this content!

The written lesson should have covered the following test + the challenge to write some tests:

///////////////////////
// Constructor Tests //
///////////////////////
address[] public tokenAddresses;
address[] public feedAddresses;

function testRevertsIfTokenLengthDoesntMatchPriceFeeds() public {
    tokenAddresses.push(weth);
    feedAddresses.push(ethUsdPriceFeed);
    feedAddresses.push(btcUsdPriceFeed);

    vm.expectRevert(DSCEngine.DSCEngine__TokenAddressesAndPriceFeedAddressesMustBeSameLength.selector);
    new DSCEngine(tokenAddresses, feedAddresses, address(dsc));
}

...

function testGetTokenAmountFromUsd() public {
        // If we want $100 of WETH @ $2000/WETH, that would be 0.05 WETH
        uint256 expectedWeth = 0.05 ether;
        uint256 amountWeth = dsce.getTokenAmountFromUsd(weth, 100 ether);
        assertEq(amountWeth, expectedWeth);
    }

....

modifier depositedCollateral() {
    vm.startPrank(USER);
    ERC20Mock(weth).approve(address(dsce), AMOUNT_COLLATERAL);
    dsce.depositCollateral(weth, AMOUNT_COLLATERAL);
    vm.stopPrank();
    _;
}

function testCanDepositedCollateralAndGetAccountInfo() public depositedCollateral {
    (uint256 totalDscMinted, uint256 collateralValueInUsd) = dsce.getAccountInformation(USER);
    uint256 expectedDepositedAmount = dsce.getTokenAmountFromUsd(weth, collateralValueInUsd);
    assertEq(totalDscMinted, 0);
    assertEq(expectedDepositedAmount, AMOUNT_COLLATERAL);
}

But it covers something about layers of testing:

Image

Image

@EngrPips
Copy link
Contributor

Hello @MrRobWeb, Thanks for raising this, but every written lesson is directly on the same page as its video content, so I will assume DSCEngine advanced testing is the video content of the Leveling up testing written lesson. @Equious, correct me if I am wrong, sir.

@MrRobWeb
Copy link
Contributor Author

MrRobWeb commented Feb 20, 2025

Hello @MrRobWeb, Thanks for raising this, but every written lesson is directly on the same page as its video content, so I will assume DSCEngine advanced testing is the video content of the Leveling up testing written lesson. @Equious, correct me if I am wrong, sir.

Hello @EngrPips , please watch the video and then check the content of written lesson. It simply doesn't match. It's completely different:
https://updraft.cyfrin.io/courses/advanced-foundry/develop-defi-protocol/defi-protocols-advanced-testings-testing?lesson_format=transcript

@EngrPips
Copy link
Contributor

I see @MrRobWeb, Thanks for pointing that out. This will be attended to appropriately as soon as possible.

@Equious
Copy link
Contributor

Equious commented Feb 21, 2025

Got this one on our radar. Thanks for the heads up. We're working out an audit of the platform as a whole, we'll get this fixed up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants