|
4 | 4 |
|
5 | 5 | from pyinjective.async_client import AsyncClient |
6 | 6 | from pyinjective.core.network import Network |
| 7 | +from pyinjective.proto.cosmos.bank.v1beta1 import query_pb2 as bank_query_pb |
| 8 | +from pyinjective.proto.cosmos.base.query.v1beta1 import pagination_pb2 as pagination_pb |
7 | 9 | from pyinjective.proto.exchange import injective_derivative_exchange_rpc_pb2, injective_spot_exchange_rpc_pb2 |
| 10 | +from tests.client.chain.grpc.configurable_bank_query_servicer import ConfigurableBankQueryServicer |
8 | 11 | from tests.client.indexer.configurable_derivative_query_servicer import ConfigurableDerivativeQueryServicer |
9 | 12 | from tests.client.indexer.configurable_spot_query_servicer import ConfigurableSpotQueryServicer |
10 | | -from tests.rpc_fixtures.markets_fixtures import ape_token_meta # noqa: F401 |
11 | | -from tests.rpc_fixtures.markets_fixtures import ape_usdt_spot_market_meta # noqa: F401 |
12 | | -from tests.rpc_fixtures.markets_fixtures import btc_usdt_perp_market_meta # noqa: F401 |
13 | | -from tests.rpc_fixtures.markets_fixtures import inj_token_meta # noqa: F401 |
14 | | -from tests.rpc_fixtures.markets_fixtures import inj_usdt_spot_market_meta # noqa: F401 |
15 | | -from tests.rpc_fixtures.markets_fixtures import usdt_perp_token_meta # noqa: F401 |
16 | | -from tests.rpc_fixtures.markets_fixtures import usdt_token_meta # noqa: F401 |
17 | | -from tests.rpc_fixtures.markets_fixtures import ( # noqa: F401; noqa: F401; noqa: F401 |
| 13 | +from tests.rpc_fixtures.markets_fixtures import ( # noqa: F401 |
| 14 | + ape_token_meta, |
| 15 | + ape_usdt_spot_market_meta, |
| 16 | + btc_usdt_perp_market_meta, |
18 | 17 | first_match_bet_market_meta, |
| 18 | + inj_token_meta, |
| 19 | + inj_usdt_spot_market_meta, |
| 20 | + smart_denom_metadata, |
| 21 | + usdt_perp_token_meta, |
| 22 | + usdt_token_meta, |
19 | 23 | usdt_token_meta_second_denom, |
20 | 24 | ) |
21 | 25 |
|
22 | 26 |
|
| 27 | +@pytest.fixture |
| 28 | +def bank_servicer(): |
| 29 | + return ConfigurableBankQueryServicer() |
| 30 | + |
| 31 | + |
23 | 32 | @pytest.fixture |
24 | 33 | def spot_servicer(): |
25 | 34 | return ConfigurableSpotQueryServicer() |
@@ -127,3 +136,44 @@ async def test_initialize_tokens_and_markets( |
127 | 136 | assert any( |
128 | 137 | (first_match_bet_market_meta.market_id == market.id for market in all_binary_option_markets.values()) |
129 | 138 | ) |
| 139 | + |
| 140 | + @pytest.mark.asyncio |
| 141 | + async def test_initialize_tokens_from_chain_denoms( |
| 142 | + self, |
| 143 | + bank_servicer, |
| 144 | + spot_servicer, |
| 145 | + derivative_servicer, |
| 146 | + smart_denom_metadata, |
| 147 | + ): |
| 148 | + pagination = pagination_pb.PageResponse( |
| 149 | + total=1, |
| 150 | + ) |
| 151 | + |
| 152 | + bank_servicer.denoms_metadata_responses.append( |
| 153 | + bank_query_pb.QueryDenomsMetadataResponse( |
| 154 | + metadatas=[smart_denom_metadata], |
| 155 | + pagination=pagination, |
| 156 | + ) |
| 157 | + ) |
| 158 | + |
| 159 | + spot_servicer.markets_responses.append(injective_spot_exchange_rpc_pb2.MarketsResponse(markets=[])) |
| 160 | + derivative_servicer.markets_responses.append(injective_derivative_exchange_rpc_pb2.MarketsResponse(markets=[])) |
| 161 | + derivative_servicer.binary_options_markets_responses.append( |
| 162 | + injective_derivative_exchange_rpc_pb2.BinaryOptionsMarketsResponse(markets=[]) |
| 163 | + ) |
| 164 | + |
| 165 | + client = AsyncClient( |
| 166 | + network=Network.local(), |
| 167 | + insecure=False, |
| 168 | + ) |
| 169 | + |
| 170 | + client.bank_api._stub = bank_servicer |
| 171 | + client.exchange_spot_api._stub = spot_servicer |
| 172 | + client.exchange_derivative_api._stub = derivative_servicer |
| 173 | + |
| 174 | + await client._initialize_tokens_and_markets() |
| 175 | + await client.initialize_tokens_from_chain_denoms() |
| 176 | + |
| 177 | + all_tokens = await client.all_tokens() |
| 178 | + assert 1 == len(all_tokens) |
| 179 | + assert smart_denom_metadata.symbol in all_tokens |
0 commit comments