Skip to content

Commit

Permalink
More fixtures in function scope
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jan 12, 2024
1 parent f402cea commit 35571d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/fixtures/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initial_balance() -> int:
return INITIAL_AMOUNT * 10**18


@pytest.fixture(scope="module")
@pytest.fixture()
def initial_amounts(pool_type, decimals, meta_decimals) -> list[int]:
return (
[INITIAL_AMOUNT * 10**precision for precision in decimals]
Expand All @@ -17,7 +17,7 @@ def initial_amounts(pool_type, decimals, meta_decimals) -> list[int]:
)


@pytest.fixture(scope="module")
@pytest.fixture()
def deposit_amounts(
initial_amounts: list[int], pool_type, pool_token_types, metapool_token_type, pool_tokens, underlying_tokens
) -> list[int]:
Expand Down
24 changes: 12 additions & 12 deletions tests/fixtures/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@
import pytest


@pytest.fixture(scope="module")
@pytest.fixture()
def gauge_interface():
return boa.load_partial("contracts/main/LiquidityGauge.vy")


@pytest.fixture(scope="module")
@pytest.fixture()
def gauge_implementation(deployer, gauge_interface):
with boa.env.prank(deployer):
return gauge_interface.deploy_as_blueprint()


@pytest.fixture(scope="module")
@pytest.fixture()
def amm_interface():
return boa.load_partial("contracts/main/CurveStableSwapNG.vy")


@pytest.fixture(scope="module")
@pytest.fixture()
def amm_implementation(deployer, amm_interface):
with boa.env.prank(deployer):
impl = amm_interface.deploy_as_blueprint()
return impl


@pytest.fixture(scope="module")
@pytest.fixture()
def amm_interface_meta():
return boa.load_partial("contracts/main/CurveStableSwapMetaNG.vy")


@pytest.fixture(scope="module")
@pytest.fixture()
def amm_implementation_meta(deployer, amm_interface_meta):
with boa.env.prank(deployer):
impl = amm_interface_meta.deploy_as_blueprint()
return impl


@pytest.fixture(scope="module")
@pytest.fixture()
def views_implementation(deployer):
with boa.env.prank(deployer):
return boa.load("contracts/main/CurveStableSwapNGViews.vy")


@pytest.fixture(scope="module")
@pytest.fixture()
def math_implementation(deployer):
with boa.env.prank(deployer):
return boa.load("contracts/main/CurveStableSwapNGMath.vy")


@pytest.fixture(scope="module")
@pytest.fixture()
def factory(
deployer,
fee_receiver,
Expand Down Expand Up @@ -103,19 +103,19 @@ def add_base_pool(
)


@pytest.fixture(scope="module")
@pytest.fixture()
def set_gauge_implementation(owner, factory, gauge_implementation):
with boa.env.prank(owner):
factory.set_gauge_implementation(gauge_implementation.address)


@pytest.fixture(scope="module")
@pytest.fixture()
def set_views_implementation(owner, factory, views_implementation):
with boa.env.prank(owner):
factory.set_views_implementation(views_implementation.address)


@pytest.fixture(scope="module")
@pytest.fixture()
def set_math_implementation(owner, factory, math_implementation):
with boa.env.prank(owner):
factory.set_math_implementation(math_implementation.address)
Expand Down
5 changes: 2 additions & 3 deletions tests/pools/test_erc4626_swaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def asset_types(pool_tokens):
return _asset_types


@pytest.fixture(scope="module")
@pytest.fixture()
def empty_swap(
deployer,
factory,
Expand Down Expand Up @@ -176,9 +176,8 @@ def deposit_amounts(pool_erc20_tokens, token_a, bob):
return _deposit_amounts


@pytest.fixture(scope="module")
@pytest.fixture()
def swap(empty_swap, bob, deposit_amounts, pool_tokens):

for token in pool_tokens:
token.approve(empty_swap, 2**256 - 1, sender=bob)
empty_swap.add_liquidity(deposit_amounts, 0, bob, sender=bob)
Expand Down

0 comments on commit 35571d2

Please sign in to comment.