mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 07:26:44 +08:00
Addressables catalog 里的 m_Crc(bundle IEEE CRC-32)此前从未解析;
声明的 size 也只作元数据、无校验能力。本次:
- ResourceEntry 新增 crc: Option<u32>(serde default 向后兼容),
compact 与 expanded 两种 catalog 形态均解析 m_Crc/m_Crc→crc
- core 新增 crc32_ieee(IEEE CRC-32,等价 zlib/Unity m_Crc)与
ResourceEntry::{declared_crc, verify_downloaded_bytes}:按声明的
size/crc 校验字节,0 视为「无 CRC」跳过
- SqliteResourceRepository 持久化 crc 列,旧库经幂等 ensure_column
迁移补列(pragma_table_info 判断后 ALTER)
- golden 投影与 fixture 补 crc 字段,验证真实形态 catalog 提取贯通
校验 API 暂不接入 import 覆盖路径(该路径按 CAS id 重写 hash/size 是
既定语义,且合成测试的声明值不匹配实际字节);接入下载/导入校验留
待 G-011。
验证:core crc32 标准向量 + verify 分支单测、expanded 形态非零 crc
提取单测、golden 端到端;core/adapters/infrastructure 全测试 + fmt +
clippy --all-targets -D warnings 全绿。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
1.3 KiB
Rust
36 lines
1.3 KiB
Rust
use bat_adapters::manifest::ManifestDriverRegistry;
|
|
use serde_json::json;
|
|
|
|
#[tokio::test]
|
|
async fn parses_real_shape_addressables_catalog_against_golden() {
|
|
let catalog = include_str!("fixtures/real_addressables/catalog.json");
|
|
let manifest = ManifestDriverRegistry::with_defaults()
|
|
.parse(catalog.as_bytes())
|
|
.await
|
|
.expect("parse real-shape Addressables catalog");
|
|
|
|
let actual = json!({
|
|
"format": format!("{:?}", manifest.format),
|
|
"locator_id": manifest.metadata.locator_id,
|
|
"cdn_prefixes": manifest.metadata.cdn_prefixes,
|
|
"resource_count": manifest.resources.len(),
|
|
"resources": manifest.resources.iter().map(|resource| {
|
|
json!({
|
|
"path": resource.path,
|
|
"hash": resource.hash,
|
|
"size": resource.size,
|
|
"resource_type": format!("{:?}", resource.resource_type),
|
|
"address": resource.address,
|
|
"dependencies": resource.dependencies,
|
|
"crc": resource.crc,
|
|
})
|
|
}).collect::<Vec<_>>(),
|
|
"metadata": manifest.metadata.extra,
|
|
});
|
|
|
|
let expected: serde_json::Value =
|
|
serde_json::from_str(include_str!("golden/real_addressables.json")).unwrap();
|
|
|
|
assert_eq!(actual, expected);
|
|
}
|