Files
hermes-agent/tests/pm/test_fixture_wheels.py
Teknium 907e3224c4 test(pm): the member wheel fixture is byte-identical when rebuilt
test_malformed_secondary_cannot_evict_recorded_member failed in CI with
`uv sync` "Hash mismatch for member-dep @ file://.../member_dep-1.0-py3-none-any.whl".

Mechanism: installing_member() rebuilds member_dep-1.0 into the same
wheels/ dir for the second plugin. _wheel used ZipFile.writestr(name, ...),
which stamps the wall clock (2-second zip resolution), so a rebuild that
crosses a tick has different bytes. The final sync seeds from home A's
recorded lock (pm/packages.py: seed = prior resolved_lock), and uv 0.13.5
keeps that lock's sha256 for an unchanged path-wheel version (uv 0.12.13
re-hashed it), so sync then verifies the new file against the old hash.
The test runs in ~2 s alone, so it passed whenever both builds fell in
one tick; CI load pushed it across.

Not caused by 07ee800dc70's relock: 7c0905a008 (rc.1) and 07ee800dc7
fail identically under the injection below.

Repro: a 2.1 s sleep before the second installing_member() call, with
uv 0.13.5 first on PATH, fails base on every run (3/3) and passes with
this fixture (3/3); uv 0.12.13 passes on base too.

Fix: fixed ZipInfo date_time and mode, so a same name/version wheel is
one artifact, as on an index. test_fixture_wheels pins it (clock moved
an hour between builds -> identical bytes; red on base).
2026-10-22 18:48:10 -07:00

18 lines
652 B
Python

"""The shared wheel fixture models an index: one name/version is one artifact."""
from __future__ import annotations
import time
from tests.pm._fixtures import _wheel
def test_rebuilt_wheel_is_byte_identical_across_a_clock_tick(tmp_path, monkeypatch):
"""A rebuild of the same wheel must hash the same, or a seeded lock fails ``uv sync``."""
(tmp_path / "a").mkdir()
(tmp_path / "b").mkdir()
first = _wheel(tmp_path / "a", "member_dep")
real_time = time.time
monkeypatch.setattr(time, "time", lambda: real_time() + 3600)
second = _wheel(tmp_path / "b", "member_dep")
assert first.read_bytes() == second.read_bytes()