9d3b36826c
Align docs so LIVE exit matches SIM fee buffer; manual full close now enters rest_seconds like auto/emergency. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
668 B
Python
23 lines
668 B
Python
from __future__ import annotations
|
|
|
|
import time
|
|
|
|
from app.models.db import Database, set_db
|
|
from app.strategy.engine import StrategyEngine
|
|
|
|
|
|
def test_enter_rest_after_close_sets_resting(tmp_path) -> None:
|
|
db = Database(tmp_path / "rest.db")
|
|
set_db(db)
|
|
db.set_setting("rest_seconds", "120")
|
|
eng = StrategyEngine()
|
|
before = int(time.time() * 1000)
|
|
eng.enter_rest_after_close()
|
|
row = db.fetchone("SELECT * FROM strategy_state WHERE id=1")
|
|
assert row is not None
|
|
assert row["phase"] == "resting"
|
|
assert int(row["rounds_done"] or 0) >= 1
|
|
until = int(row["rest_until_ms"] or 0)
|
|
assert until >= before + 100_000
|
|
db.close()
|