Register `MarketNotFound` for Binance RPC errors
A lookup for `btcusdt.binance` already reports the missing venue in the child actor. The caller gets the same hint, but Tractor leaves `RemoteActorError.boxed_type` unset. Its registry only knows the direct `BrokerError` subclasses that piker hands it at import. Deats, - Register `MarketNotFound` alongside those direct subclasses. It inherits from `SymbolNotFound` one level further down. - Call Binance’s `get_mkt_info()` over a local Tractor portal and check both the exception class and the expected FQME in the parent. The missing venue exercises the failure before exchange lookup, so the regression runs offline. (this patch was generated in some part by `Codex` using `GPT-6` (`OpenAI`))wkt/land_binance_usdm_feed
parent
e403404d8f
commit
3529157559
|
|
@ -119,6 +119,7 @@ class SchemaMismatch(BrokerError):
|
|||
reg_err_types([
|
||||
BrokerError,
|
||||
*BrokerError.__subclasses__(),
|
||||
MarketNotFound, # indirect subclass via SymbolNotFound
|
||||
])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.<venue>.binance' in str(exc)
|
||||
|
||||
trio.run(main)
|
||||
Loading…
Reference in New Issue