fix: 默认心跳先等够再报,新登录账号可以立刻开始

This commit is contained in:
2026-11-16 02:44:54 +08:00
parent ec41af9489
commit e27b3002a4
5 changed files with 62 additions and 22 deletions
+7
View File
@@ -42,3 +42,10 @@ def fresh_database():
from euniv.proxy_pool import _holds
_holds.clear()
from euniv import autostudy as autostudy_mod
autostudy_mod._wanted.clear()
autostudy_mod._user_halts.clear()
users = autostudy_mod._status.get("users")
if isinstance(users, dict):
users.clear()
+10 -6
View File
@@ -120,16 +120,15 @@ def test_wait_stop_timeout_and_event() -> None:
asyncio.run(main())
def test_jitter_zero_means_no_wait() -> None:
assert _jitter(0) == 0
assert _jitter(-1) == 0
def test_jitter_never_sends_early() -> None:
assert _jitter(0) == 1
assert _jitter(-1) == 1
for _ in range(30):
wait = _jitter(1)
assert 0 <= wait < 5
assert abs(wait - 1) <= 0.3
assert 1.3 <= wait <= 4
for _ in range(30):
wait = _jitter(10)
assert 7 <= wait <= 13
assert 10.3 <= wait <= 13.3
def test_count_total_estimates_from_progress() -> None:
@@ -322,6 +321,11 @@ class _VideoSession:
def test_video_refresh_hours_when_finished(monkeypatch) -> None:
monkeypatch.setattr("euniv.autostudy._update_month_hours", lambda *_args: None)
async def no_wait(*_args, **_kwargs) -> bool:
return False
monkeypatch.setattr("euniv.autostudy._heartbeat_wait", no_wait)
async def main() -> None:
session = _VideoSession("700")
global_stop = asyncio.Event()