🐞 fix(DSCEngineTest): fix testRevertsIfTransferFromFails
function logic
#125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's a clear explanation of the issue for my PR:
Issue in
test_RevertIfTransferIsFailed
functionThe current implementation of the
test_RevertIfTransferIsFailed
test has several unnecessary and potentially confusing elements:Incorrect DSC token parameter: The test incorrectly passes the mock token (
mockCollateralToken
) as the third parameter to theDSCEngine
constructor, which should actually be the DSC token address. This is confusing as it mixes the collateral token and the stablecoin token roles.Unnecessary ownership transfer: The test transfers ownership of
mockCollateralToken
to themockDsce
. This step is unnecessary since we're only testing thedepositCollateral
function, which doesn't require any owner-only permissions on the token.Redundant address tracking: The test uses an explicit
owner
variable andvm.startPrank(owner)
when deploying contracts, but this is unnecessary as the default sender in tests is already the test contract itself.Proposed fix
The test can be simplified to focus clearly on its purpose - verifying that
DSCEngine
correctly handles a failedtransferFrom
operation during collateral deposit:This simplified version: