Skip to content

Commit

Permalink
test: testing stablecoin lens
Browse files Browse the repository at this point in the history
  • Loading branch information
heswithme committed Oct 16, 2024
1 parent 8940456 commit 0035eb5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contracts/RewardsHandler.vy
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ event ScalingFactorUpdated:


event StablecoinLensUpdated:
new_lens: IStablecoinLens
new_stablecoin_lens: IStablecoinLens


################################################################
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ def controller_factory():
return boa.from_etherscan(ab.crvusd_controller_factory, "controller_factory")


@pytest.fixture()
def lens(controller_factory):
return boa.load("contracts/StablecoinLens.vy", controller_factory)


@pytest.fixture()
def vault_factory():
return boa.from_etherscan(ab.yearn_vault_factory, "vault_factory")
Expand Down Expand Up @@ -101,21 +96,26 @@ def minimum_weight():


@pytest.fixture()
def rewards_handler(vault, minimum_weight):
def rewards_handler(vault, minimum_weight, stablecoin_lens):
rh = boa.load(
"contracts/RewardsHandler.vy",
ab.crvusd,
vault,
stablecoin_lens,
minimum_weight, # 5%
10_000, # 1
ab.crvusd_controller_factory,
ab.dao_agent,
)
vault.set_role(rh, 2**11 | 2**5, sender=ab.dao_agent)

return rh


@pytest.fixture()
def stablecoin_lens():
return boa.load("contracts/StablecoinLens.vy", ab.crvusd_controller_factory)


@pytest.fixture()
def active_controllers(fee_splitter):
# useful to call dispatch_fees
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_dynamic_weight.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def raw_weight() -> uint256:


def test_fee_splitter_cap(
fee_splitter, crvusd, vault, rewards_handler, active_controllers, new_depositor
fee_splitter, crvusd, vault, rewards_handler, active_controllers, new_depositor, stablecoin_lens
):
# test were we ask for so much that we hit the cap
fee_splitter_cap = fee_splitter.receivers(0)[1]

circulating_supply = rewards_handler.eval("lens._circulating_supply()")
circulating_supply = stablecoin_lens.circulating_supply()

# with the supply at the time of the fork
# if we deposit 10_000_000 crvUSD in the vault
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/test_stablecoin_lens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FORK_BLOCK_SUPPLY = 62182303636759107878108289


def test_circulating_supply(stablecoin_lens):
# circ supply for block of fork
assert stablecoin_lens.circulating_supply() == FORK_BLOCK_SUPPLY
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import boa


def test_default_behavior(rewards_handler):
new_lens = boa.env.generate_address()
rewards_handler.internal._set_stablecoin_lens(new_lens)
assert rewards_handler.stablecoin_lens() == new_lens
19 changes: 19 additions & 0 deletions tests/unitary/rewards_handler/test_set_stablecoin_lens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import boa


def test_default_behavior(rewards_handler, rate_manager):
new_lens = boa.env.generate_address()
rewards_handler.set_stablecoin_lens(new_lens, sender=rate_manager)
events = rewards_handler.get_logs()

# Verify event emission
assert f"StablecoinLensUpdated(new_stablecoin_lens={new_lens}" in repr(events)

assert rewards_handler.stablecoin_lens() == new_lens


def test_role_access(rewards_handler):
with boa.reverts("access_control: account is missing role"):
rewards_handler.set_stablecoin_lens(
boa.env.generate_address(), sender=boa.env.generate_address()
)

0 comments on commit 0035eb5

Please sign in to comment.