Skip to content

Commit

Permalink
Reset env between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jan 22, 2024
1 parent ab7de7b commit 9e39e58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
]


@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(autouse=True)
def fast_mode():
boa.env.enable_fast_mode()
yield
boa.reset_env()


def pytest_generate_tests(metafunc):
Expand Down
14 changes: 6 additions & 8 deletions tests/fixtures/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,27 @@ def meta_setup(
underlying_tokens,
pool_tokens,
add_initial_liquidity_owner_meta,
metapool_token,
):
approve_account(alice, pool_tokens, meta_swap)
mint_account(alice, pool_tokens, initial_balance, meta_initial_amounts)
mint_for_testing(bob, 1 * 10**18, None, True)

underlying_token = underlying_tokens[0]
add_base_pool_liquidity(alice, base_pool, base_pool_tokens, base_pool_decimals)
alice_bp_balance_norm = base_pool_lp_token.balanceOf(alice) / 10**18
alice_mp_balance_norm = underlying_token.balanceOf(alice) / 10 ** underlying_token.decimals()
alice_mp_balance_norm = metapool_token.balanceOf(alice) / 10 ** metapool_token.decimals()

if alice_mp_balance_norm < alice_bp_balance_norm:
mint_for_testing(
alice, int(math.ceil(alice_bp_balance_norm) * 10 ** underlying_token.decimals()), underlying_token
)
mint_for_testing(alice, int(math.ceil(alice_bp_balance_norm) * 10 ** metapool_token.decimals()), metapool_token)

with boa.env.prank(alice):
underlying_token.approve(meta_swap.address, 2**256 - 1)
metapool_token.approve(meta_swap.address, 2**256 - 1)
base_pool_lp_token.approve(meta_swap.address, 2**256 - 1)
meta_swap.add_liquidity(deposit_meta_amounts, 0)

add_base_pool_liquidity(bob, base_pool, base_pool_tokens, base_pool_decimals)
mint_for_testing(bob, initial_balance, underlying_token, False)
assert underlying_token.balanceOf(bob) == pytest.approx(base_pool_lp_token.balanceOf(bob))
mint_for_testing(bob, initial_balance, metapool_token, False)
assert metapool_token.balanceOf(bob) == pytest.approx(base_pool_lp_token.balanceOf(bob))

with boa.env.prank(bob):
for underlying_token in underlying_tokens:
Expand Down

0 comments on commit 9e39e58

Please sign in to comment.