generated from Badger-Finance/badger-strategy-mix-v1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_remBadger_unit.py
120 lines (84 loc) · 3.65 KB
/
test_remBadger_unit.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import brownie
from brownie import *
from helpers.constants import MaxUint256
from helpers.SnapshotManager import SnapshotManager
from helpers.time import days
"""
TODO: Put your tests here to prove the strat is good!
See test_harvest_flow, for the basic tests
See test_strategy_permissions, for tests at the permissions level
"""
def test_brick_permissions(deployer, sett, rando, strategist, governance):
with brownie.reverts("onlyGovernance"):
sett.brickDeposits({"from": strategist})
with brownie.reverts("onlyGovernance"):
sett.brickDeposits({"from": rando})
sett.brickDeposits({"from": governance})
def test_mint_permissions(deployer, sett, rando, strategist, governance):
with brownie.reverts("onlyGovernance"):
sett.mintExtra(123, {"from": strategist})
with brownie.reverts("onlyGovernance"):
sett.mintExtra(123, {"from": rando})
sett.mintExtra(123, {"from": governance})
def test_brick_blocks_mint_permissions(deployer, sett, rando, strategist, governance):
sett.brickDeposits({"from": governance})
with brownie.reverts("You can mint extra only until you brick deposits"):
sett.mintExtra(123, {"from": governance})
def test_mint_blocks_deposits_permissions(deployer, sett, rando, strategist, governance):
"""
Equivalent to saying you can only mint once
"""
sett.mintExtra(123, {"from": governance})
with brownie.reverts("You can mint extra only until you brick deposits"):
sett.mintExtra(123, {"from": governance})
def test_brick_blocks_deposits_not_withdraw(deployer, sett, strategy, controller, want, governance):
# Setup
startingBalance = want.balanceOf(deployer)
depositAmount = startingBalance // 6
assert startingBalance >= depositAmount
assert startingBalance >= 0
# End Setup
assert want.balanceOf(sett) == 0
want.approve(sett, MaxUint256, {"from": deployer})
## Works
sett.deposit(depositAmount, {"from": deployer})
sett.withdraw(depositAmount / 10, {"from": deployer})
sett.brickDeposits({"from": governance})
## Deposits are bricked, can't deposit anymore
with brownie.reverts():
sett.deposit(depositAmount, {"from": deployer})
## Can still withdraw
sett.withdraw(depositAmount / 10, {"from": deployer})
sett.withdrawAll({"from": deployer})
def test_mint_mints_exact(deployer, sett, strategy, controller, want, governance):
assert sett.totalSupply() == 0
sett.mintExtra(123, {"from": governance})
assert sett.totalSupply() == 123
def test_mint_mints_exact_after_seeded(deployer, sett, strategy, controller, want, governance):
# Setup
startingBalance = want.balanceOf(deployer)
depositAmount = startingBalance // 6
assert startingBalance >= depositAmount
assert startingBalance >= 0
# End Setup
assert want.balanceOf(sett) == 0
want.approve(sett, MaxUint256, {"from": deployer})
## Works
sett.deposit(depositAmount, {"from": deployer})
assert sett.totalSupply() == depositAmount
sett.mintExtra(123, {"from": governance})
assert sett.totalSupply() == depositAmount + 123
def test_mint_mints_exact_after_seeded(deployer, sett, strategy, controller, want, governance):
# Setup
startingBalance = want.balanceOf(deployer)
depositAmount = startingBalance // 6
assert startingBalance >= depositAmount
assert startingBalance >= 0
# End Setup
assert want.balanceOf(sett) == 0
want.approve(sett, MaxUint256, {"from": deployer})
## Works
sett.deposit(depositAmount, {"from": deployer})
assert sett.totalSupply() == depositAmount
sett.mintExtra(123, {"from": governance})
assert sett.totalSupply() == depositAmount + 123