-
Notifications
You must be signed in to change notification settings - Fork 104
test: fix broken unitary tests #104
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from tests.utils.constants import WAD | ||
|
|
||
| COLLATERAL = 10**21 | ||
| DEBT = 10**18 | ||
| RATE = 10**11 | ||
| TIME_DELTA = 86400 | ||
|
|
||
|
|
||
| def test_default_behavior_no_fees(controller, market_type): | ||
| expected_fee = WAD if market_type == "mint" else 0 | ||
| assert controller.admin_percentage() == expected_fee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| def test_default_behavior_no_fees(controller): | ||
| """Naive check to make sure the function is exported, actual test is in the internal tests.""" | ||
| assert controller.collect_fees() == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import pytest | ||
|
|
||
| import boa | ||
|
|
||
| from tests.utils import filter_logs, max_approve | ||
| from tests.utils.constants import MIN_TICKS, WAD | ||
|
|
||
| COLLATERAL = 10**21 | ||
| DEBT = 10**18 | ||
| RATE = 10**11 | ||
| TIME_DELTA = 86400 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("pct", range(1, 101)) | ||
| def test_default_behavior( | ||
| controller, | ||
| amm, | ||
| borrowed_token, | ||
| collateral_token, | ||
| factory, | ||
| pct, | ||
| market_type, | ||
| ): | ||
| controller.eval(f"core.admin_percentage = {WAD * pct // 100}") | ||
| boa.deal(collateral_token, boa.env.eoa, COLLATERAL) | ||
| max_approve(collateral_token, controller) | ||
| controller.create_loan(COLLATERAL, DEBT, MIN_TICKS) | ||
|
|
||
| amm.eval(f"self.rate = {RATE}") | ||
| amm.eval("self.rate_time = block.timestamp") | ||
| boa.env.time_travel(TIME_DELTA) | ||
|
|
||
| expected_fees = DEBT * TIME_DELTA * RATE // 10**18 * pct // 100 | ||
|
|
||
| fee_receiver = factory.fee_receiver() | ||
| receiver_balance_before = borrowed_token.balanceOf(fee_receiver) | ||
| controller_balance_before = borrowed_token.balanceOf(controller) | ||
|
|
||
| amount = controller.collect_fees() | ||
|
|
||
| if pct > 0: | ||
| assert expected_fees > 0 | ||
| assert amount > 0 | ||
| else: | ||
| assert amount == 0 | ||
|
|
||
| logs = filter_logs(controller, "CollectFees") | ||
| assert len(logs) == 1 | ||
| assert logs[0].amount == amount | ||
| assert logs[0].new_supply == controller.eval("core._total_debt.initial_debt") | ||
|
|
||
| receiver_balance_after = borrowed_token.balanceOf(fee_receiver) | ||
| controller_balance_after = borrowed_token.balanceOf(controller) | ||
| assert receiver_balance_after - receiver_balance_before == amount | ||
| assert controller_balance_before - controller_balance_after == amount | ||
|
|
||
| assert controller.admin_fees() == 0 | ||
| assert controller.eval("core.collected") == amount | ||
| assert amount == expected_fees | ||
38 changes: 0 additions & 38 deletions
38
tests/unitary/lending/lend_controller/test_admin_percentage_lc.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
tests/unitary/lending/lend_controller/test_borrow_more_lc.py
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
tests/unitary/lending/lend_controller/test_collect_fees_lc.py
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
tests/unitary/lending/lend_controller/test_create_loan_lc.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.