fix: preserve sell event routing owner
This commit is contained in:
@@ -63,6 +63,38 @@ def test_buy_intent_persists_transition(pg_clean):
|
||||
assert slot.status is SlotState.PENDING_BUY and slot.symbol == "005930"
|
||||
|
||||
|
||||
def test_sell_admission_owner_survives_postgresql_repository_restart(pg_clean):
|
||||
repo, svc, intents = _wire(pg_clean)
|
||||
repo.reconcile_universe(INST, _SYMS)
|
||||
decision = intents.submit_buy(BuyIntent(
|
||||
intent_id="pg-owner-buy",
|
||||
qty=10,
|
||||
strategy_id="BUY-A",
|
||||
portfolio_id="PF-1",
|
||||
))
|
||||
assert decision.slot_id is not None
|
||||
svc.transit_slot(
|
||||
decision.slot_id,
|
||||
SlotState.PENDING_BUY,
|
||||
SlotState.HOLDING,
|
||||
reason="filled",
|
||||
actor="test",
|
||||
qty=10.0,
|
||||
avg_price=1000.0,
|
||||
)
|
||||
sell = intents.submit_sell(SellIntent(
|
||||
intent_id="pg-owner-sell",
|
||||
slot_id=decision.slot_id,
|
||||
sell_strategy_id="SELL-B",
|
||||
))
|
||||
assert sell.admitted
|
||||
|
||||
reloaded = PostgreSQLSlotRepository(pg_clean).fetch_slot(decision.slot_id)
|
||||
assert reloaded is not None
|
||||
assert reloaded.status is SlotState.PENDING_SELL
|
||||
assert reloaded.sell_strategy_id == "SELL-B"
|
||||
|
||||
|
||||
def test_buy_intent_idempotent_on_pg(pg_clean):
|
||||
repo, svc, intents = _wire(pg_clean)
|
||||
repo.reconcile_universe(INST, _SYMS)
|
||||
|
||||
Reference in New Issue
Block a user