Skip to content

Commit

Permalink
testfiles cleanup, remove some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
heswithme committed Sep 27, 2024
1 parent 3b9261b commit 4b35525
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 152 deletions.
133 changes: 66 additions & 67 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ package-mode = false

[tool.poetry.dependencies]
python = "^3.10"
poetry = "1.8.3"
poetry = "^1.8.0"
vyper = "0.3.10"
pycryptodome = "^3.18.0"
pre-commit = "^3.3.3"
titanoboa-zksync = {git = "https://github.com/DanielSchiavini/titanoboa-zksync.git", tag = "v0.1.2"} # inherits titanoboa 0.1.10

[tool.poetry.group.dev.dependencies]
black = "22.3.0"
flake8 = "4.0.1"
isort = "5.12.0"
mamushi = "^0.0.2a1"
black = "^24.0.0"
flake8 = "^7.0.0"
isort = "^5.0.0"
mamushi = "^0.0.4a3"


[tool.poetry.group.testing.dependencies]
Expand Down
18 changes: 2 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@


def pytest_generate_tests(metafunc):
# some targeted debug
# if metafunc.function.__name__ == "test_price_ema_remove_imbalance":
# print("Debugging...")
# metafunc.parametrize("pool_type", [0])
# metafunc.parametrize("pool_token_types", [(0, 0)])
# # metafunc.parametrize("sending,receiving", [(0, 1)])
# metafunc.parametrize("metapool_token_type", [None])
# metafunc.parametrize("initial_decimals", [(18, 18)])
# return
# Combined parametrization of pool_type and metapool_token_type (to avoid repeating tests in basic_pools
# for various metapool_token_types)

if ALL_TOKEN_PAIRS and not EXTENSIVE_TOKEN_PAIRS:
metafunc.definition.add_marker(pytest.mark.all_token_pairs)
if EXTENSIVE_TOKEN_PAIRS:
Expand Down Expand Up @@ -92,17 +80,15 @@ def get_pool_token_pairs(metafunc):
items = get_tokens_for_metafunc(metafunc)
# make all combinations possible
all_combinations = list(combinations_with_replacement(items, 2)) # 6 combinations (1,0 == 0,1)
all_all_combinations = list(product(items, items)) # 9 combinations (1,0 != 0,1)
extensive_combinations = list(product(items, items)) # 9 combinations (1,0 != 0,1)
if len(all_combinations) < 2 or metafunc.definition.get_closest_marker("all_token_pairs"):
return all_combinations
if metafunc.definition.get_closest_marker("extensive_token_pairs"):
return all_all_combinations
return extensive_combinations
# make sure we get the same result in each worker
random = Random(len(metafunc.fixturenames))
# take 2 combinations for smaller test set
return sorted(random.sample(all_combinations, k=2))
# Q: why sample only 2 when we have 6? and even 9?
# todo - ideally we test all possible combinations
# dev: added all_ and extensive_token_pairs marker to test all combinations


Expand Down
11 changes: 0 additions & 11 deletions tests/fixtures/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def basic_setup(
pool_tokens,
metapool_token_type,
):
# assert metapool_token_type is not None, "Fixture required downstream"
# bob and alice have tokens from pool
for user in [alice, bob]:
mint_account(user, pool_tokens, initial_balance, basic_initial_amounts)
Expand All @@ -173,14 +172,6 @@ def basic_setup(
with boa.env.prank(alice):
basic_swap.add_liquidity(deposit_basic_amounts, 0)

# mint_account(bob, pool_tokens, initial_balance, basic_initial_amounts)
# approve_account(bob, pool_tokens, basic_swap)
# @dev small cleanup, code was not consistent
# mint_for_testing(bob, 1 * 10**18, None, True)
# with boa.env.prank(bob):
# for token in pool_tokens:
# token.approve(basic_swap.address, 2**256 - 1)


@pytest.fixture()
def meta_setup(
Expand All @@ -196,8 +187,6 @@ def meta_setup(
meta_initial_amounts,
underlying_tokens,
pool_tokens,
# add_initial_liquidity_owner_meta, # - this fixture leads to doubled liquidity in metapool,
# results in failing some tests
metapool_token,
):
approve_account(alice, pool_tokens, meta_swap)
Expand Down
2 changes: 1 addition & 1 deletion tests/pools/exchange/test_exchange_reverts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_insufficient_balance(
# the transfer of tokens. Otherwise, the pool is safe.
# !!!!!!! Fixed with changing rebase logic to not rebase at 0 transfer !!!!!!!!!!
#
# what is not fixed - is that this min function transfers 0 evein if
# what is not fixed - is that this min function transfers 0 even if
# non-0 is requested, and this bypasses dx > 0 assert in the contract,
# resulting in a 0->swap (that fails the test in some cases)
# Thus still skipping problematic tests.
Expand Down
Loading

0 comments on commit 4b35525

Please sign in to comment.