@@ -80,20 +80,6 @@ def hashes_length_modifier(timestamp: Timestamp) -> None:
8080 def setUp (self ) -> None :
8181 self .trusted_set = TrustedMetadataSet (self .metadata ["root" ])
8282
83- def _root_updated_and_update_timestamp (
84- self , timestamp_bytes : Optional [bytes ] = None
85- ) -> None :
86- """Finsh root update and update timestamp with passed timestamp_bytes.
87-
88- Args:
89- timestamp_bytes:
90- Bytes used when calling trusted_set.update_timestamp().
91- Default self.metadata["timestamp"].
92-
93- """
94- timestamp_bytes = timestamp_bytes or self .metadata ["timestamp" ]
95- self .trusted_set .update_timestamp (timestamp_bytes )
96-
9783
9884 def _update_all_besides_targets (
9985 self ,
@@ -111,7 +97,9 @@ def _update_all_besides_targets(
11197 Default self.metadata["snapshot"].
11298
11399 """
114- self ._root_updated_and_update_timestamp (timestamp_bytes )
100+
101+ timestamp_bytes = timestamp_bytes or self .metadata ["timestamp" ]
102+ self .trusted_set .update_timestamp (timestamp_bytes )
115103 snapshot_bytes = snapshot_bytes or self .metadata ["snapshot" ]
116104 self .trusted_set .update_snapshot (snapshot_bytes )
117105
@@ -247,7 +235,7 @@ def version_modifier(timestamp: Timestamp) -> None:
247235 timestamp .version = 3
248236
249237 timestamp = self .modify_metadata ("timestamp" , version_modifier )
250- self ._root_updated_and_update_timestamp (timestamp )
238+ self .trusted_set . update_timestamp (timestamp )
251239 with self .assertRaises (exceptions .ReplayedMetadataError ):
252240 self .trusted_set .update_timestamp (self .metadata ["timestamp" ])
253241
@@ -257,7 +245,7 @@ def bump_snapshot_version(timestamp: Timestamp) -> None:
257245
258246 # set current known snapshot.json version to 2
259247 timestamp = self .modify_metadata ("timestamp" , bump_snapshot_version )
260- self ._root_updated_and_update_timestamp (timestamp )
248+ self .trusted_set . update_timestamp (timestamp )
261249
262250 # newtimestamp.meta["snapshot.json"].version < trusted_timestamp.meta["snapshot.json"].version
263251 with self .assertRaises (exceptions .ReplayedMetadataError ):
@@ -282,13 +270,13 @@ def modify_snapshot_length(timestamp: Timestamp) -> None:
282270
283271 # set known snapshot.json length to 1
284272 timestamp = self .modify_metadata ("timestamp" , modify_snapshot_length )
285- self ._root_updated_and_update_timestamp (timestamp )
273+ self .trusted_set . update_timestamp (timestamp )
286274
287275 with self .assertRaises (exceptions .RepositoryError ):
288276 self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
289277
290278 def test_update_snapshot_cannot_verify_snapshot_with_threshold (self ):
291- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
279+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
292280 snapshot = Metadata .from_bytes (self .metadata ["snapshot" ])
293281 snapshot .signatures .clear ()
294282 with self .assertRaises (exceptions .UnsignedMetadataError ):
@@ -299,7 +287,7 @@ def timestamp_version_modifier(timestamp: Timestamp) -> None:
299287 timestamp .meta ["snapshot.json" ].version = 2
300288
301289 timestamp = self .modify_metadata ("timestamp" , timestamp_version_modifier )
302- self ._root_updated_and_update_timestamp (timestamp )
290+ self .trusted_set . update_timestamp (timestamp )
303291
304292 #intermediate snapshot is allowed to not match meta version
305293 self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
@@ -320,7 +308,7 @@ def remove_file_from_meta(snapshot: Snapshot) -> None:
320308 self .trusted_set .update_snapshot (snapshot )
321309
322310 def test_update_snapshot_meta_version_decreases (self ):
323- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
311+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
324312
325313 def version_meta_modifier (snapshot : Snapshot ) -> None :
326314 snapshot .meta ["targets.json" ].version += 1
@@ -332,7 +320,7 @@ def version_meta_modifier(snapshot: Snapshot) -> None:
332320 self .trusted_set .update_snapshot (self .metadata ["snapshot" ])
333321
334322 def test_update_snapshot_expired_new_snapshot (self ):
335- self ._root_updated_and_update_timestamp (self .metadata ["timestamp" ])
323+ self .trusted_set . update_timestamp (self .metadata ["timestamp" ])
336324 def snapshot_expired_modifier (snapshot : Snapshot ) -> None :
337325 snapshot .expires = datetime (1970 , 1 , 1 )
338326
0 commit comments