diff --git a/tests/fixtures/tokens.py b/tests/fixtures/tokens.py index 323eaffb..f2a16c72 100644 --- a/tests/fixtures/tokens.py +++ b/tests/fixtures/tokens.py @@ -43,7 +43,8 @@ def pool_tokens(pool_token_types, request): # <--------------------- Metapool configuration ---------------------> @pytest.fixture() -def metapool_token(metapool_token_type, request): +def metapool_token(metapool_token_type, request, initial_decimals): + assert initial_decimals, "Fixture required for requesting `decimals` downstream" fixture = { TOKEN_TYPES["plain"]: "plain_tokens", TOKEN_TYPES["oracle"]: "oracle_tokens", diff --git a/tests/pools/oracle/test_oracle.py b/tests/pools/oracle/test_oracle.py index cca93ea9..849f7fb5 100644 --- a/tests/pools/oracle/test_oracle.py +++ b/tests/pools/oracle/test_oracle.py @@ -1,7 +1,7 @@ import boa import pytest -from tests.constants import POOL_TYPES +from tests.constants import POOL_TYPES, TOKEN_TYPES from tests.fixtures.accounts import add_base_pool_liquidity, mint_account from tests.fixtures.constants import INITIAL_AMOUNT from tests.utils.tokens import mint_for_testing @@ -15,12 +15,22 @@ def initial_setup_alice(pool_type, request): Set up the initial state for Alice. Run either the basic or meta fixture depending on the pool type. """ - fixture_name = {POOL_TYPES["basic"]: "basic_setup_alice", POOL_TYPES["meta"]: "meta_setup_alice"}[pool_type] - return request.getfixturevalue(fixture_name) + fixtures = {POOL_TYPES["basic"]: "basic_setup_alice", POOL_TYPES["meta"]: "meta_setup_alice"} + return request.getfixturevalue(fixtures[pool_type]) @pytest.fixture() -def basic_setup_alice(alice, initial_amounts, initial_balance, oracle_tokens, basic_swap): +def basic_setup_alice( + alice, + initial_amounts, + initial_balance, + oracle_tokens, + basic_swap, + base_pool_tokens, + base_pool, + base_pool_decimals, + underlying_tokens, +): mint_for_testing(alice, 1 * 10**18, None, True) mint_account(alice, oracle_tokens, initial_balance, initial_amounts) with boa.env.prank(alice): @@ -52,22 +62,22 @@ def test_initial_liquidity( oracle_tokens, metapool_token, ): - amounts = [] - if pool_type == 0: - for i, t in enumerate(pool_token_types): - if t != 1: - amounts.append(DEPOSIT_AMOUNT * 10 ** decimals[i]) - else: - amounts.append(DEPOSIT_AMOUNT * 10 ** decimals[i] * 10**18 // oracle_tokens[i].exchangeRate()) + amounts = [ + DEPOSIT_AMOUNT * 10 ** decimals[i] * 10**18 // oracle_tokens[i].exchangeRate() + if t == TOKEN_TYPES["oracle"] + else DEPOSIT_AMOUNT * 10 ** decimals[i] + for i, t in enumerate(pool_token_types) + ] else: - if metapool_token_type == 1: - amounts = [ + amounts = ( + [ DEPOSIT_AMOUNT * 10**meta_decimals * 10**18 // metapool_token.exchangeRate(), DEPOSIT_AMOUNT * 10**18, ] - else: - amounts = [DEPOSIT_AMOUNT * 10**meta_decimals, DEPOSIT_AMOUNT * 10**18] + if metapool_token_type == 1 + else [DEPOSIT_AMOUNT * 10**meta_decimals, DEPOSIT_AMOUNT * 10**18] + ) swap.add_liquidity(amounts, 0, sender=alice) swap.add_liquidity(amounts, 0, sender=alice)