Open
Description
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:
Metadata
Assignees
Labels
No labels
Activity