-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathtest_revoke.py
35 lines (29 loc) · 1.23 KB
/
test_revoke.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
def test_revoke_strategy_from_vault(
chain, token, vault, strategy, amount, user, gov, RELATIVE_APPROX
):
# Deposit to the vault and harvest
token.approve(vault.address, amount, {"from": user})
vault.deposit(amount, {"from": user})
chain.sleep(1)
strategy.harvest()
assert pytest.approx(strategy.estimatedTotalAssets(), rel=RELATIVE_APPROX) == amount
# In order to pass this tests, you will need to implement prepareReturn.
# TODO: uncomment the following lines.
# vault.revokeStrategy(strategy.address, {"from": gov})
# chain.sleep(1)
# strategy.harvest()
# assert pytest.approx(token.balanceOf(vault.address), rel=RELATIVE_APPROX) == amount
def test_revoke_strategy_from_strategy(
chain, token, vault, strategy, amount, gov, user, RELATIVE_APPROX
):
# Deposit to the vault and harvest
token.approve(vault.address, amount, {"from": user})
vault.deposit(amount, {"from": user})
chain.sleep(1)
strategy.harvest()
assert pytest.approx(strategy.estimatedTotalAssets(), rel=RELATIVE_APPROX) == amount
strategy.setEmergencyExit()
chain.sleep(1)
strategy.harvest()
assert pytest.approx(token.balanceOf(vault.address), rel=RELATIVE_APPROX) == amount