test: pin the expiry window and close settlement review gaps

This commit is contained in:
2026-09-10 05:20:56 -04:00
parent b1bc06e2b1
commit 5e2c35a812
5 changed files with 30 additions and 3 deletions
+16
View File
@@ -585,6 +585,22 @@ class TestCancellationSettlement:
await mw(_REQ)
assert (await limiter.source_stats("a")).tpm_used == 0
async def test_circuit_open_rejection_settles_zero_end_to_end(self):
"""S1 端到端: 开路拒绝的 pick 预扣后按 0 结算, 不给 tpm_used 增加任何量。"""
clock = FakeClock()
script = [TransientError(str(i)) for i in range(9)]
mw, limiter, *_ = _harness(
[_src("a", max_concurrency=1, tpm=10000, est_tokens=400)],
script,
clock=clock,
max_attempts=99,
)
# 3 次瞬时失败后 a 开路 → 第 4 次 pick 被拒绝
with pytest.raises(CircuitOpenError):
await mw(_REQ)
# 三次瞬时失败各保留 est = 1200; 开路那次 pick 若漏了 settle(0) 会再 +400
assert (await limiter.source_stats("a")).tpm_used == 1200
class TestCancellation:
async def test_cancel_mid_flight_releases_permit(self):