-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathconftest.py
97 lines (67 loc) · 2.27 KB
/
conftest.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
import pytest
from brownie import config
from brownie import Contract
@pytest.fixture
def gov(accounts):
yield accounts.at("0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52", force=True)
@pytest.fixture
def user(accounts):
yield accounts[0]
@pytest.fixture
def rewards(accounts):
yield accounts[1]
@pytest.fixture
def guardian(accounts):
yield accounts[2]
@pytest.fixture
def management(accounts):
yield accounts[3]
@pytest.fixture
def strategist(accounts):
yield accounts[4]
@pytest.fixture
def keeper(accounts):
yield accounts[5]
@pytest.fixture
def token():
token_address = "0x6b175474e89094c44da98b954eedeac495271d0f" # this should be the address of the ERC-20 used by the strategy/vault (DAI)
yield Contract(token_address)
@pytest.fixture
def amount(accounts, token, user):
amount = 10_000 * 10 ** token.decimals()
# In order to get some funds for the token you are about to use,
# it impersonate an exchange address to use it's funds.
reserve = accounts.at("0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", force=True)
token.transfer(user, amount, {"from": reserve})
yield amount
@pytest.fixture
def weth():
token_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
yield Contract(token_address)
@pytest.fixture
def weth_amount(user, weth):
weth_amount = 10 ** weth.decimals()
user.transfer(weth, weth_amount)
yield weth_amount
@pytest.fixture
def vault(pm, gov, rewards, guardian, management, token):
Vault = pm(config["dependencies"][0]).Vault
vault = guardian.deploy(Vault)
vault.initialize(token, gov, rewards, "", "", guardian, management)
vault.setDepositLimit(2**256 - 1, {"from": gov})
vault.setManagement(management, {"from": gov})
yield vault
@pytest.fixture
def strategy(strategist, keeper, vault, Strategy, gov):
strategy = strategist.deploy(Strategy, vault)
strategy.setKeeper(keeper)
vault.addStrategy(strategy, 10_000, 0, 2**256 - 1, 1_000, {"from": gov})
yield strategy
@pytest.fixture(scope="session")
def RELATIVE_APPROX():
yield 1e-5
# Function scoped isolation fixture to enable xdist.
# Snapshots the chain before each test and reverts after test completion.
@pytest.fixture(scope="function", autouse=True)
def shared_setup(fn_isolation):
pass