修正QIMEI UUID42随机段生成

This commit is contained in:
yml2213
2026-09-02 17:15:06 +08:00
parent 17ee943753
commit 1f3773de28
4 changed files with 32 additions and 12 deletions
+17 -1
View File
@@ -61,6 +61,22 @@ def test_qimei_uuid42_matches_sdk_vectors_and_random_upper_bound():
assert all(ch in "0123456789abcdef" for ch in upper)
def test_qimei_uuid42_uses_twenty_independent_random_draws(monkeypatch):
values = iter(value / 16 for value in (*range(16), *range(4)))
calls = 0
def next_random():
nonlocal calls
calls += 1
return next(values)
monkeypatch.setattr("core.huya.web_cookie_fields.random.random", next_random)
assert _qimei_uuid42_generate(1700000000000000000) == (
"17b0f060d14100b2230123456789abcdef012396a9"
)
assert calls == 20
def test_qimei_uuid42_encodes_local_date_and_cookie_flag():
base = 1700000000000000000
assert _qimei_uuid42_generate(base, random_value=0, cookie_enabled=False) == (
@@ -75,7 +91,7 @@ def test_qimei_uuid42_handles_year_zero_padding():
def test_sdk_uuid42_trace_vectors_have_confirmed_outer_layout():
"""锁定 SDK 追踪确认的 14+4+20+4 外层布局,不约束未闭合的替换算法。"""
"""锁定 SDK 追踪确认的 14+4+20+4 外层布局和固定随机向量。"""
vectors = {
0.0: "17b0f060d1410085cc000000000000000000003207",
0.25: "17b0f060d14100037f4444444444444444444437df",