Skip to content

Fix inconsistent behaviour of compute_metafile_hashes_length #1695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/repository_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,15 @@ def update_timestamp(self) -> None:
"""Update timestamp and assign snapshot version to snapshot_meta
version.
"""
self.timestamp.snapshot_meta.version = self.snapshot.version

hashes = None
length = None
if self.compute_metafile_hashes_length:
hashes, length = self._compute_hashes_and_length(Snapshot.type)
self.timestamp.snapshot_meta.hashes = hashes
self.timestamp.snapshot_meta.length = length

self.timestamp.snapshot_meta = MetaFile(
self.snapshot.version, length, hashes
)

self.timestamp.version += 1

Expand Down
14 changes: 14 additions & 0 deletions tests/test_updater_top_level_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,20 @@ def test_new_targets_expired(self) -> None:

self._assert_files_exist([Root.type, Timestamp.type, Snapshot.type])

def test_compute_metafile_hashes_length(self) -> None:
self.sim.compute_metafile_hashes_length = True
self.sim.update_snapshot()
self._run_refresh()
self._assert_version_equals("timestamp", 2)
self._assert_version_equals("snapshot", 2)

self.sim.compute_metafile_hashes_length = False
self.sim.update_snapshot()
self._run_refresh()

self._assert_version_equals("timestamp", 3)
self._assert_version_equals("snapshot", 3)


if __name__ == "__main__":

Expand Down