-
Notifications
You must be signed in to change notification settings - Fork 25
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
Encapsulation of initialization variables and minor refactoring of BaseTest #1191
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
function setDefaultAccountBalance(uint256 balance) internal { | ||
if (_initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isInitialized()
is never called; could call it here, or we don't need it.
} | ||
|
||
function defaultAccountBalance() internal view returns (uint256) { | ||
return _defaultAccountBalance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require
that it be initialized? Could even lazy initialize it, if there's a reasonable default. Like if it's not initialized, set it to a global default and then set _initialized. If a particular test wants to use a different specific value, it can just be sure to call setDefaultAccountBalance
before anything that references it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or make a virtual defaultAccountBalance()
that just returns the standard value, and if tests want something different, they can override it?
/** | ||
* @notice Manipulate rates of ERC4626 tokens. | ||
* @dev It's important to not have a 1:1 rate when testing ERC4626 tokens, so we can differentiate between | ||
* wrapped and underlying amounts. For certain tests, we may need to override these rates for simplicity. | ||
*/ | ||
function mockERC4626TokenRates() internal virtual { | ||
waDAI.inflateUnderlyingOrWrapped(0, 6 * defaultBalance); | ||
waUSDC.inflateUnderlyingOrWrapped(23 * defaultBalance, 0); | ||
waDAI.inflateUnderlyingOrWrapped(0, 6 * _defaultAccountBalance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the function consistently, instead of the variable directly (as it's internal)?
Description
A variable that we initialize before setUp, defaultAccountBalance has been encapsulated in a separate method to be able to get a readable error and prevent uncontrolled changes to this variable.
Type of change
Checklist:
main
, or there's a description of how to mergeIssue Resolution