@@ -274,9 +274,25 @@ def version_modifier(timestamp: Timestamp) -> None:
274274 with self .assertRaises (exceptions .BadVersionNumberError ):
275275 self .trusted_set .update_timestamp (self .metadata [Timestamp .type ])
276276
277+ def test_update_timestamp_with_same_timestamp (self ) -> None :
278+ # Test that timestamp is NOT updated if:
279+ # new_timestamp.version == trusted_timestamp.version
280+ self .trusted_set .update_timestamp (self .metadata [Timestamp .type ])
281+ initial_timestamp = self .trusted_set .timestamp
282+
283+ # Update timestamp with the same version.
284+ with self .assertRaises (exceptions .EqualVersionNumberError ):
285+ self .trusted_set .update_timestamp ((self .metadata [Timestamp .type ]))
286+
287+ # Every object has a unique id() if they are equal, this means timestamp
288+ # was not updated.
289+ self .assertEqual (id (initial_timestamp ), id (self .trusted_set .timestamp ))
290+
277291 def test_update_timestamp_snapshot_ver_below_current (self ) -> None :
278292 def bump_snapshot_version (timestamp : Timestamp ) -> None :
279293 timestamp .snapshot_meta .version = 2
294+ # The timestamp version must be increased to initiate a update.
295+ timestamp .version += 1
280296
281297 # set current known snapshot.json version to 2
282298 timestamp = self .modify_metadata (Timestamp .type , bump_snapshot_version )
@@ -382,6 +398,8 @@ def snapshot_expired_modifier(snapshot: Snapshot) -> None:
382398 def test_update_snapshot_successful_rollback_checks (self ) -> None :
383399 def meta_version_bump (timestamp : Timestamp ) -> None :
384400 timestamp .snapshot_meta .version += 1
401+ # The timestamp version must be increased to initiate a update.
402+ timestamp .version += 1
385403
386404 def version_bump (snapshot : Snapshot ) -> None :
387405 snapshot .version += 1
0 commit comments