From 91400bcd366cd57a7784d1c7f87379f755fa38ca Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Fri, 8 Dec 2023 09:48:11 +0100 Subject: [PATCH] Fix last tests --- README.md | 24 +++++--------- .../api/test_find_pool_for_coins.py | 16 ++++++--- .../metaregistry/api/test_get_pool_name.py | 33 +++++++++++-------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index b8cdc31..c5fdccc 100644 --- a/README.md +++ b/README.md @@ -393,7 +393,7 @@ Set up the python environment using the following steps: ``` -This project uses `titanoboa`. +This project uses [`titanoboa`](https://github.com/vyperlang/titanoboa) for deployment and testing. ### Testing @@ -441,21 +441,13 @@ The following command simulates metaregistry setup. For Prod transactions, set n #### Deployments Ethereum Mainnet: - - -`base_pool_registry`: [0xDE3eAD9B2145bBA2EB74007e58ED07308716B725](https://etherscan.io/address/0xDE3eAD9B2145bBA2EB74007e58ED07308716B725#code) - -`crypto_registry`: [0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0](https://etherscan.io/address/0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0#code) - -`stable_registry_handler`: [0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68](https://etherscan.io/address/0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68#code) - -`stable_factory_handler`: [0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9](https://etherscan.io/address/0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9#code) - -`crypto_registry_handler`: [0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56](https://etherscan.io/address/0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56#code) - -`crypto_factory_handler`: [0xC4F389020002396143B863F6325aA6ae481D19CE](https://etherscan.io/address/0xC4F389020002396143B863F6325aA6ae481D19CE#code) - -`metaregistry`: [0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC](https://etherscan.io/address/0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC#code) +- `base_pool_registry`: [0xDE3eAD9B2145bBA2EB74007e58ED07308716B725](https://etherscan.io/address/0xDE3eAD9B2145bBA2EB74007e58ED07308716B725#code) +- `crypto_registry`: [0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0](https://etherscan.io/address/0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0#code) +- `stable_registry_handler`: [0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68](https://etherscan.io/address/0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68#code) +- `stable_factory_handler`: [0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9](https://etherscan.io/address/0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9#code) +- `crypto_registry_handler`: [0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56](https://etherscan.io/address/0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56#code) +- `crypto_factory_handler`: [0xC4F389020002396143B863F6325aA6ae481D19CE](https://etherscan.io/address/0xC4F389020002396143B863F6325aA6ae481D19CE#code) +- `metaregistry`: [0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC](https://etherscan.io/address/0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC#code) ### License diff --git a/tests/mainnet/metaregistry/api/test_find_pool_for_coins.py b/tests/mainnet/metaregistry/api/test_find_pool_for_coins.py index 35e1ef4..2d4d930 100644 --- a/tests/mainnet/metaregistry/api/test_find_pool_for_coins.py +++ b/tests/mainnet/metaregistry/api/test_find_pool_for_coins.py @@ -19,7 +19,8 @@ def _get_all_combinations(metaregistry, pool): # there exist some pools with an LP token as the first coin, that's incorrect # example: 0xf5d5305790c1af08e9df44b30a1afe56ccda72df - is_first_coin_lp_token = metaregistry.get_pool_from_lp_token(first_coin) + lp_token_pool = metaregistry.get_pool_from_lp_token(first_coin) + is_first_coin_lp_token = lp_token_pool and lp_token_pool != ZERO_ADDRESS if metaregistry.is_meta(pool) and not is_first_coin_lp_token: underlying_coins = [ @@ -46,8 +47,13 @@ def test_all(populated_metaregistry, pool): pools_containing_pair = populated_metaregistry.find_pools_for_coins( coin1, coin2 ) - assert pool in pools_containing_pair + assert pool in pools_containing_pair, ( + f"Cannot find pool {pool} for coin combination {coin1} and {coin2}. " + f"Pools found {pools_containing_pair}" + ) - for i, found_pool in enumerate(pools_containing_pair): - pool = populated_metaregistry.find_pool_for_coins(coin1, coin2, i) - assert pool == found_pool + # test with specified index + assert pools_containing_pair == [ + populated_metaregistry.find_pool_for_coins(coin1, coin2, i) + for i in range(len(pools_containing_pair)) + ] diff --git a/tests/mainnet/metaregistry/api/test_get_pool_name.py b/tests/mainnet/metaregistry/api/test_get_pool_name.py index fbd0301..b9fed83 100644 --- a/tests/mainnet/metaregistry/api/test_get_pool_name.py +++ b/tests/mainnet/metaregistry/api/test_get_pool_name.py @@ -18,23 +18,28 @@ def test_stable_factory_pools(populated_metaregistry, stable_factory_pool): stable_factory_pool ) ) - num_registry_handlers = len( - handler != ZERO_ADDRESS for handler in pool_registry_handlers + pool_registry_handlers = [ + handler + for handler in pool_registry_handlers + if handler != ZERO_ADDRESS + ] + num_registry_handlers = len(pool_registry_handlers) + + pool_name = populated_metaregistry.get_pool_name(stable_factory_pool) + token_name = get_deployed_contract("ERC20", stable_factory_pool).name() + assert num_registry_handlers in (1, 2), ( + f"Invalid number of registry handlers for {stable_factory_pool}. " + f"Metaregistry returned {num_registry_handlers} handlers: {pool_registry_handlers}" ) - - name = populated_metaregistry.get_pool_name(stable_factory_pool) - token_contract = get_deployed_contract("ERC20", stable_factory_pool) if num_registry_handlers == 1: - assert name == token_contract.name() - else: - assert name != token_contract.name() - - pool_name2 = populated_metaregistry.get_pool_name( - stable_factory_pool, 1 - ) - assert pool_name2 == token_contract.name() + assert pool_name == token_name + return - assert num_registry_handlers in (1, 2) + assert pool_name != token_name + second_pool_name = populated_metaregistry.get_pool_name( + stable_factory_pool, 1 + ) + assert second_pool_name == token_name def test_crypto_registry_pools(