Skip to content

Commit 355c3a9

Browse files
author
abel
committed
(fix) Added unit test for AsyncClient tokens loading logic, to improve coverage
1 parent 9e8fc8a commit 355c3a9

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/test_async_client.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,74 @@ async def test_initialize_tokens_and_markets(
141141
(first_match_bet_market_meta.market_id == market.id for market in all_binary_option_markets.values())
142142
)
143143

144+
@pytest.mark.asyncio
145+
async def test_tokens_and_markets_initialization_read_tokens_from_official_list(
146+
self,
147+
spot_servicer,
148+
derivative_servicer,
149+
inj_usdt_spot_market_meta,
150+
ape_usdt_spot_market_meta,
151+
btc_usdt_perp_market_meta,
152+
first_match_bet_market_meta,
153+
aioresponses,
154+
):
155+
test_network = Network.local()
156+
157+
tokens_list = [
158+
{
159+
"address": "ibc/2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E",
160+
"isNative": True,
161+
"tokenVerification": "verified",
162+
"name": "USD Coin",
163+
"decimals": 6,
164+
"symbol": "USDC",
165+
"logo": "https://imagedelivery.net/DYKOWp0iCc0sIkF-2e4dNw/a8bfa5f1-1dab-4be9-a68c-e15f0bd11100/public",
166+
"coinGeckoId": "usd-coin",
167+
"baseDenom": "uusdc",
168+
"channelId": "channel-148",
169+
"source": "cosmos",
170+
"path": "transfer/channel-148",
171+
"hash": "2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E",
172+
"denom": "ibc/2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E",
173+
"tokenType": "ibc",
174+
"externalLogo": "usdc.png",
175+
},
176+
{
177+
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
178+
"isNative": False,
179+
"decimals": 18,
180+
"symbol": "WMATIC",
181+
"logo": "https://imagedelivery.net/DYKOWp0iCc0sIkF-2e4dNw/0d061e1e-a746-4b19-1399-8187b8bb1700/public",
182+
"name": "Wrapped Matic",
183+
"coinGeckoId": "wmatic",
184+
"denom": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
185+
"tokenType": "evm",
186+
"tokenVerification": "verified",
187+
"externalLogo": "polygon.png",
188+
},
189+
]
190+
aioresponses.get(test_network.official_tokens_list_url, payload=tokens_list)
191+
192+
spot_servicer.markets_responses.append(injective_spot_exchange_rpc_pb2.MarketsResponse(markets=[]))
193+
derivative_servicer.markets_responses.append(injective_derivative_exchange_rpc_pb2.MarketsResponse(markets=[]))
194+
derivative_servicer.binary_options_markets_responses.append(
195+
injective_derivative_exchange_rpc_pb2.BinaryOptionsMarketsResponse(markets=[])
196+
)
197+
198+
client = AsyncClient(
199+
network=test_network,
200+
insecure=False,
201+
)
202+
203+
client.exchange_spot_api._stub = spot_servicer
204+
client.exchange_derivative_api._stub = derivative_servicer
205+
206+
await client._initialize_tokens_and_markets()
207+
208+
all_tokens = await client.all_tokens()
209+
for token_info in tokens_list:
210+
assert token_info["symbol"] in all_tokens
211+
144212
@pytest.mark.asyncio
145213
async def test_initialize_tokens_from_chain_denoms(
146214
self,

0 commit comments

Comments
 (0)