Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066233
D1235.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D1235.diff
View Options
diff --git a/swh/indexer/tests/utils.py b/swh/indexer/tests/utils.py
--- a/swh/indexer/tests/utils.py
+++ b/swh/indexer/tests/utils.py
@@ -5,7 +5,6 @@
import abc
import datetime
-import hashlib
import random
from hypothesis import strategies
@@ -481,20 +480,15 @@
'entries': DIRECTORY,
}])
for (obj_id, content) in OBJ_STORAGE_DATA.items():
- # TODO: use MultiHash
- if hasattr(hashlib, 'blake2s'):
- blake2s256 = hashlib.blake2s(content, digest_size=32).digest()
- else:
- # fallback for Python <3.6
- blake2s256 = bytes([random.randint(0, 255) for _ in range(32)])
+ content_hashes = hashutil.MultiHash.from_data(content).digest()
storage.content_add([{
'data': content,
'length': len(content),
'status': 'visible',
'sha1': hash_to_bytes(obj_id),
'sha1_git': hash_to_bytes(obj_id),
- 'sha256': hashlib.sha256(content).digest(),
- 'blake2s256': blake2s256
+ 'sha256': content_hashes['sha256'],
+ 'blake2s256': content_hashes['blake2s256']
}])
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 3:04 AM (10 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3213898
Attached To
D1235: Use hashutil.MultiHash in swh.indexer.tests.test_utils.fill_storage
Event Timeline
Log In to Comment