Skip to content

Commit

Permalink
Add tests for all cexex comparing unsupported assets to mapping
Browse files Browse the repository at this point in the history
This is so that we don't add a mapping to a specific asset thinking we
have fixed the mapping but have also forgotten it in the unsupported
assets list like we did in this issue:
rotki#3702 (comment)
  • Loading branch information
LefterisJP committed Nov 18, 2021
1 parent 3048f40 commit cd1e5d5
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
5 changes: 4 additions & 1 deletion rotkehlchen/tests/exchanges/test_binance.py
Expand Up @@ -9,7 +9,7 @@

import pytest

from rotkehlchen.assets.asset import Asset
from rotkehlchen.assets.asset import WORLD_TO_BINANCE, Asset
from rotkehlchen.assets.converters import UNSUPPORTED_BINANCE_ASSETS, asset_from_binance
from rotkehlchen.constants.assets import A_ADA, A_BNB, A_BTC, A_DOT, A_ETH, A_EUR, A_USDT, A_WBTC
from rotkehlchen.constants.timing import DEFAULT_TIMEOUT_TUPLE
Expand Down Expand Up @@ -178,6 +178,9 @@ def test_binance_assets_are_known(
database,
inquirer, # pylint: disable=unused-argument
):
unsupported_assets = set(UNSUPPORTED_BINANCE_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_BINANCE.values()))
assert not common_items, f'Binance assets {common_items} should not be unsupported'
# use a real binance instance so that we always get the latest data
binance = Binance(
name='binance1',
Expand Down
4 changes: 4 additions & 0 deletions rotkehlchen/tests/exchanges/test_bitfinex.py
Expand Up @@ -7,6 +7,7 @@
import pytest

from rotkehlchen.accounting.structures import Balance
from rotkehlchen.assets.asset import WORLD_TO_BITFINEX
from rotkehlchen.assets.converters import (
BITFINEX_EXCHANGE_TEST_ASSETS,
UNSUPPORTED_BITFINEX_ASSETS,
Expand Down Expand Up @@ -38,6 +39,9 @@ def test_name():
def test_assets_are_known(mock_bitfinex):
"""This tests only exchange (trades) assets (not margin, nor futures ones).
"""
unsupported_assets = set(UNSUPPORTED_BITFINEX_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_BITFINEX.values()))
assert not common_items, f'Bitfinex assets {common_items} should not be unsupported'
currencies_response = mock_bitfinex._query_currencies()
if currencies_response.success is False:
response = currencies_response.response
Expand Down
5 changes: 4 additions & 1 deletion rotkehlchen/tests/exchanges/test_bittrex.py
@@ -1,7 +1,7 @@
import warnings as test_warnings
from unittest.mock import patch

from rotkehlchen.assets.asset import Asset
from rotkehlchen.assets.asset import WORLD_TO_BITTREX, Asset
from rotkehlchen.assets.converters import UNSUPPORTED_BITTREX_ASSETS, asset_from_bittrex
from rotkehlchen.constants.assets import A_BTC, A_ETH, A_LTC
from rotkehlchen.constants.misc import ZERO
Expand Down Expand Up @@ -34,6 +34,9 @@ def test_name():


def test_bittrex_assets_are_known(bittrex):
unsupported_assets = set(UNSUPPORTED_BITTREX_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_BITTREX.values()))
assert not common_items, f'Bittrex assets {common_items} should not be unsupported'
currencies = bittrex.get_currencies()
for bittrex_asset in currencies:
symbol = bittrex_asset['symbol']
Expand Down
4 changes: 3 additions & 1 deletion rotkehlchen/tests/exchanges/test_ftx.py
Expand Up @@ -4,7 +4,7 @@

import pytest

from rotkehlchen.assets.asset import Asset
from rotkehlchen.assets.asset import WORLD_TO_FTX, Asset
from rotkehlchen.assets.converters import UNSUPPORTED_FTX_ASSETS, asset_from_ftx
from rotkehlchen.constants import ZERO
from rotkehlchen.constants.assets import A_1INCH, A_ETH, A_USD, A_USDC
Expand All @@ -28,6 +28,8 @@ def test_ftx_exchange_assets_are_known(mock_ftx: Ftx):

unknown_assets: Set[str] = set()
unsupported_assets = set(UNSUPPORTED_FTX_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_FTX.values()))
assert not common_items, f'FTX assets {common_items} should not be unsupported'

def process_currency(currency: Optional[str]):
"""Check if a currency is known for the FTX exchange"""
Expand Down
4 changes: 4 additions & 0 deletions rotkehlchen/tests/exchanges/test_gemini.py
Expand Up @@ -4,6 +4,7 @@
import pytest
import requests

from rotkehlchen.assets.asset import WORLD_TO_GEMINI
from rotkehlchen.assets.converters import UNSUPPORTED_GEMINI_ASSETS
from rotkehlchen.constants.assets import A_BCH, A_BTC, A_ETH, A_LINK, A_LTC, A_USD
from rotkehlchen.constants.misc import ZERO
Expand Down Expand Up @@ -63,6 +64,9 @@ def test_gemini_all_symbols_are_known(sandbox_gemini):
Use the real gemini API
"""
unsupported_assets = set(UNSUPPORTED_GEMINI_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_GEMINI.values()))
assert not common_items, f'Gemini assets {common_items} should not be unsupported'
symbols = sandbox_gemini._public_api_query('symbols')
for symbol in symbols:
try:
Expand Down
7 changes: 5 additions & 2 deletions rotkehlchen/tests/exchanges/test_iconomi.py
@@ -1,8 +1,8 @@
import warnings as test_warnings
from unittest.mock import patch

from rotkehlchen.assets.asset import Asset
from rotkehlchen.assets.converters import asset_from_iconomi
from rotkehlchen.assets.asset import WORLD_TO_ICONOMI, Asset
from rotkehlchen.assets.converters import UNSUPPORTED_ICONOMI_ASSETS, asset_from_iconomi
from rotkehlchen.constants.assets import A_ETH, A_EUR, A_REP
from rotkehlchen.errors import UnknownAsset
from rotkehlchen.exchanges.iconomi import Iconomi
Expand Down Expand Up @@ -96,6 +96,9 @@ def test_iconomi_assets_are_known(
database,
inquirer, # pylint: disable=unused-argument
):
unsupported_assets = set(UNSUPPORTED_ICONOMI_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_ICONOMI.values()))
assert not common_items, f'Iconomi assets {common_items} should not be unsupported'
# use a real Iconomi instance so that we always get the latest data
iconomi = Iconomi(
name='iconomi1',
Expand Down
3 changes: 3 additions & 0 deletions rotkehlchen/tests/exchanges/test_kucoin.py
Expand Up @@ -8,6 +8,7 @@
import requests

from rotkehlchen.accounting.structures import Balance
from rotkehlchen.assets.asset import WORLD_TO_KUCOIN
from rotkehlchen.assets.converters import UNSUPPORTED_KUCOIN_ASSETS, asset_from_kucoin
from rotkehlchen.constants.assets import A_BTC, A_ETH, A_LINK, A_USDT
from rotkehlchen.errors import RemoteError, UnknownAsset, UnsupportedAsset
Expand Down Expand Up @@ -54,6 +55,8 @@ def test_kucoin_exchange_assets_are_known(mock_kucoin):

# Extract the unique symbols from the exchange pairs
unsupported_assets = set(UNSUPPORTED_KUCOIN_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_KUCOIN.values()))
assert not common_items, f'Kucoin assets {common_items} should not be unsupported'
for entry in response_dict['data']:
symbol = entry['currency']
try:
Expand Down
5 changes: 4 additions & 1 deletion rotkehlchen/tests/exchanges/test_poloniex.py
Expand Up @@ -3,7 +3,7 @@

import pytest

from rotkehlchen.assets.asset import Asset
from rotkehlchen.assets.asset import WORLD_TO_POLONIEX, Asset
from rotkehlchen.assets.converters import UNSUPPORTED_POLONIEX_ASSETS, asset_from_poloniex
from rotkehlchen.constants.assets import A_BCH, A_BTC, A_ETH
from rotkehlchen.errors import DeserializationError, UnknownAsset, UnsupportedAsset
Expand Down Expand Up @@ -344,6 +344,9 @@ def mock_api_return(url, req, **kwargs): # pylint: disable=unused-argument


def test_poloniex_assets_are_known(poloniex):
unsupported_assets = set(UNSUPPORTED_POLONIEX_ASSETS)
common_items = unsupported_assets.intersection(set(WORLD_TO_POLONIEX.values()))
assert not common_items, f'Poloniex assets {common_items} should not be unsupported'
currencies = poloniex.return_currencies()
for poloniex_asset in currencies.keys():
try:
Expand Down

0 comments on commit cd1e5d5

Please sign in to comment.