Skip to content

Commit

Permalink
Fix last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Dec 8, 2023
1 parent 947bea8 commit 91400bc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
16 changes: 11 additions & 5 deletions tests/mainnet/metaregistry/api/test_find_pool_for_coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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))
]
33 changes: 19 additions & 14 deletions tests/mainnet/metaregistry/api/test_get_pool_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 91400bc

Please sign in to comment.