diff --git a/piker/brokers/_util.py b/piker/brokers/_util.py index 3049f4dc..b45ef426 100644 --- a/piker/brokers/_util.py +++ b/piker/brokers/_util.py @@ -119,6 +119,7 @@ class SchemaMismatch(BrokerError): reg_err_types([ BrokerError, *BrokerError.__subclasses__(), + MarketNotFound, # indirect subclass via SymbolNotFound ]) diff --git a/tests/providers/test_binance_market_lookup.py b/tests/providers/test_binance_market_lookup.py new file mode 100644 index 00000000..e8d8cd27 --- /dev/null +++ b/tests/providers/test_binance_market_lookup.py @@ -0,0 +1,53 @@ +''' +Binance market lookup errors across Tractor RPC. + +''' +import pytest +import tractor +import trio + +from piker.brokers import MarketNotFound +from piker.brokers.binance import feed as binance_feed + + +def test_missing_venue_error_over_rpc( + reg_addr: tuple[str, int|str], +) -> None: + ''' + Preserve Binance's missing-venue error across an actor boundary. + + - A market with no venue fails before exchange lookup. The + parent receives the diagnostic even if Tractor cannot resolve + the concrete exception in its local error registry. + - Call ``get_mkt_info()`` in a child and check both the expected + market format and ``RemoteActorError.boxed_type``. Direct + calls cannot expose a missing IPC exception registration. + + ''' + async def main() -> None: + ''' + Send the invalid market through the child's RPC endpoint. + + ''' + async with ( + tractor.open_root_actor(registry_addrs=[reg_addr]), + tractor.open_nursery() as an, + ): + portal: tractor.Portal = await an.start_actor( + 'binance_lookup', + enable_modules=[binance_feed.__name__], + ) + with pytest.raises(tractor.RemoteActorError) as raised: + await portal.run_from_ns( + binance_feed.__name__, + 'get_mkt_info', + fqme='btcusdt.binance', + ) + + await portal.cancel_actor() + + exc: tractor.RemoteActorError = raised.value + assert exc.boxed_type is MarketNotFound + assert 'expected-form>> btcusdt..binance' in str(exc) + + trio.run(main)