test: align blackout queue mocks with overflow counter contract
This commit is contained in:
15
src/main.py
15
src/main.py
@@ -1031,19 +1031,10 @@ def _maybe_queue_order_intent(
|
||||
price: float,
|
||||
source: str,
|
||||
) -> bool:
|
||||
def _coerce_nonnegative_int(value: Any) -> int:
|
||||
try:
|
||||
parsed = int(value)
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
return max(0, parsed)
|
||||
|
||||
if not BLACKOUT_ORDER_MANAGER.in_blackout():
|
||||
return False
|
||||
|
||||
before_overflow_drops = _coerce_nonnegative_int(
|
||||
getattr(BLACKOUT_ORDER_MANAGER, "overflow_drop_count", 0)
|
||||
)
|
||||
before_overflow_drops = BLACKOUT_ORDER_MANAGER.overflow_drop_count
|
||||
queued = BLACKOUT_ORDER_MANAGER.enqueue(
|
||||
_build_queued_order_intent(
|
||||
market=market,
|
||||
@@ -1055,9 +1046,7 @@ def _maybe_queue_order_intent(
|
||||
)
|
||||
)
|
||||
if queued:
|
||||
after_overflow_drops = _coerce_nonnegative_int(
|
||||
getattr(BLACKOUT_ORDER_MANAGER, "overflow_drop_count", 0)
|
||||
)
|
||||
after_overflow_drops = BLACKOUT_ORDER_MANAGER.overflow_drop_count
|
||||
logger.warning(
|
||||
(
|
||||
"Blackout active: queued order intent %s %s (%s) "
|
||||
|
||||
@@ -6502,6 +6502,7 @@ async def test_blackout_queues_order_and_skips_submission() -> None:
|
||||
blackout_manager.in_blackout.return_value = True
|
||||
blackout_manager.enqueue.return_value = True
|
||||
blackout_manager.pending_count = 1
|
||||
blackout_manager.overflow_drop_count = 0
|
||||
|
||||
with patch("src.main.BLACKOUT_ORDER_MANAGER", blackout_manager):
|
||||
await trading_cycle(
|
||||
|
||||
Reference in New Issue
Block a user