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

test: add blue tests #134

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

test: add blue tests #134

wants to merge 2 commits into from

Conversation

Jean-Grimal
Copy link
Contributor

Fixes #129

@Jean-Grimal Jean-Grimal marked this pull request as ready for review April 11, 2024 13:33

vm.warp(timeElapsed);

morpho.accrueInterest(marketParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to test that the accrued intereste are in a certain range (approximate it very roughly). This is because forgetting the line fixedRateIrm.setBorrowRate would still make the test pass, which is a bit loose IMO.
Could do the same thing for the adaptive curve IRM, although finding a rough estimate is a bit harder

uint256 internal constant MIN_TEST_AMOUNT = 100;
uint256 internal constant MAX_TEST_AMOUNT = 1e28;
uint256 internal constant MIN_TIME_ELAPSED = 10;
uint256 internal constant MAX_TIME_ELAPSED = 315360000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where dois this value come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for MAX_TEST_AMOUNT and MIN_TEST_AMOUNT I used the same ones as we use for blue tests
MIN_TIME_ELAPSED is 10sec (approx one block)
MAX_TIME_ELAPSED is 315360000 sec (ten years)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can just use 10 year instead then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's no longer available since solc 0.5.0

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write 10 * 365 days though

Comment on lines +14 to +16
"build:blue": "yarn --cwd lib/morpho-blue/ build:forge --out ../../out/",
"build:hardhat": "hardhat compile",
"test:forge": "FOUNDRY_PROFILE=test forge test",
"test:forge": "yarn build:blue && FOUNDRY_PROFILE=test forge test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we agree to only use the "import files technique" from now, which is more robust

uint256 internal constant MIN_TEST_AMOUNT = 100;
uint256 internal constant MAX_TEST_AMOUNT = 1e28;
uint256 internal constant MIN_TIME_ELAPSED = 10;
uint256 internal constant MAX_TIME_ELAPSED = 315360000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's no longer available since solc 0.5.0

image

uint256 internal constant MIN_TEST_AMOUNT = 100;
uint256 internal constant MAX_TEST_AMOUNT = 1e28;
uint256 internal constant MIN_TIME_ELAPSED = 10;
uint256 internal constant MAX_TIME_ELAPSED = 315360000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write 10 * 365 days though


uint256 internal constant MIN_TEST_AMOUNT = 100;
uint256 internal constant MAX_TEST_AMOUNT = 1e28;
uint256 internal constant MIN_TIME_ELAPSED = 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Comment on lines +37 to +39
IAdaptiveCurveIrm internal adaptiveCurveIrm =
IAdaptiveCurveIrm(deployCode("AdaptiveCurveIrm.sol", abi.encode(address(morpho))));
IFixedRateIrm public fixedRateIrm = IFixedRateIrm(deployCode("FixedRateIrm.sol"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we instead have one test that tests with all the IRMs (not sure how to do this) , and all their configs (That is why I was more thinking about doing some formal verification here, maybe with halmos?) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of properties you are thinking of @MathisGD ? For some of them I think fuzzing would be more appropriate because bounds are not "hardcoded". For example, if the fixed rate IRM has a given rate then we could check that, fuzzing the parameters, this is "more or less" the rate that borrowers get over time. This "more or less" is not formal and difficult to put in a specification. But it would not be difficult with fuzzing, just use approxEqRel with some well-chosen percentage

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

Successfully merging this pull request may close these issues.

General IRM test suite
4 participants