test: add deferred phase 8 adversarial matrix

This commit is contained in:
2026-07-23 10:49:48 +00:00
parent 3d09e32ccd
commit 69709c778b
11 changed files with 820 additions and 2 deletions
+42
View File
@@ -12,6 +12,48 @@ from archive_control.v1 import resource_pb2
class ResourceTests(unittest.TestCase):
def test_pure_v2_identity_and_single_file_tree_normalization(self):
info = {
b"file tree": {
b"": {
b"length": 3,
b"pieces root": b"x" * 32,
},
},
b"meta version": 2,
b"name": b"v2.bin",
b"piece length": 16384,
}
metainfo_bytes = encode({b"info": info})
decoded = decode_metainfo(metainfo_bytes)
self.assertEqual(decoded.info_hash_v1_hex, "")
self.assertEqual(
decoded.info_hash_v2_hex,
hashlib.sha256(encode(info)).hexdigest(),
)
self.assertEqual(decoded.files[0].path, "v2.bin")
normalized = normalize_resource(
{
"hash": decoded.info_hash_v2_hex,
"name": "v2.bin",
"state": "stoppedUP",
},
[{
"index": 0,
"name": "v2.bin",
"size": 3,
"completed": 3,
"priority": 1,
}],
metainfo_bytes,
)
self.assertEqual(
normalized.summary.resource_id.info_hash_v2_hex,
decoded.info_hash_v2_hex,
)
self.assertFalse(normalized.summary.resource_id.info_hash_v1_hex)
def test_hybrid_identity_and_selection_normalization(self):
info = {
b"file tree": {