20260427 拆分独立repo-bytes.db数据库文件,cir materialize 移除旧兼容
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use rpki::blob_store::ExternalRepoBytesDb;
|
||||
use rpki::cir::{
|
||||
CIR_VERSION_V1, CanonicalInputRepresentation, CirHashAlgorithm, CirObject, CirTal, encode_cir,
|
||||
materialize_cir,
|
||||
materialize_cir_from_repo_bytes,
|
||||
};
|
||||
|
||||
fn skip_heavy_script_replay_test() -> bool {
|
||||
@@ -55,12 +56,13 @@ fn build_ta_only_cir() -> (CanonicalInputRepresentation, Vec<u8>) {
|
||||
)
|
||||
}
|
||||
|
||||
fn write_static(root: &Path, date: &str, bytes: &[u8]) {
|
||||
fn write_repo_bytes(repo_bytes_db: &Path, bytes: &[u8]) {
|
||||
use sha2::{Digest, Sha256};
|
||||
let hash = hex::encode(Sha256::digest(bytes));
|
||||
let dir = root.join(date).join(&hash[0..2]).join(&hash[2..4]);
|
||||
std::fs::create_dir_all(&dir).expect("mkdir static");
|
||||
std::fs::write(dir.join(hash), bytes).expect("write static object");
|
||||
ExternalRepoBytesDb::open(repo_bytes_db)
|
||||
.expect("open repo bytes")
|
||||
.put_blob_bytes_batch(&[(hash, bytes.to_vec())])
|
||||
.expect("write repo bytes");
|
||||
}
|
||||
|
||||
fn prepare_reference_ccr(
|
||||
@@ -118,7 +120,7 @@ fn ours_sequence_replay_script_replays_all_steps() {
|
||||
}
|
||||
let td = tempfile::tempdir().expect("tempdir");
|
||||
let sequence_root = td.path().join("sequence");
|
||||
let static_root = sequence_root.join("static");
|
||||
let repo_bytes_db = sequence_root.join("repo-bytes.db");
|
||||
let mirror_root = td.path().join("mirror");
|
||||
std::fs::create_dir_all(sequence_root.join("full")).unwrap();
|
||||
std::fs::create_dir_all(sequence_root.join("delta-001")).unwrap();
|
||||
@@ -137,8 +139,8 @@ fn ours_sequence_replay_script_replays_all_steps() {
|
||||
&cir_bytes,
|
||||
)
|
||||
.unwrap();
|
||||
write_static(&static_root, "20260407", &ta_bytes);
|
||||
materialize_cir(&cir, &static_root, &mirror_root, true).unwrap();
|
||||
write_repo_bytes(&repo_bytes_db, &ta_bytes);
|
||||
materialize_cir_from_repo_bytes(&cir, &repo_bytes_db, &mirror_root, true).unwrap();
|
||||
let reference = prepare_reference_ccr(td.path(), &cir, &mirror_root);
|
||||
std::fs::copy(&reference, sequence_root.join("full").join("result.ccr")).unwrap();
|
||||
std::fs::copy(
|
||||
@@ -157,7 +159,7 @@ fn ours_sequence_replay_script_replays_all_steps() {
|
||||
|
||||
let sequence = serde_json::json!({
|
||||
"version": 1,
|
||||
"staticRoot": "static",
|
||||
"repoBytesDbPath": "repo-bytes.db",
|
||||
"steps": [
|
||||
{"stepId":"full","kind":"full","validationTime":"2026-04-07T00:00:00Z","cirPath":"full/input.cir","ccrPath":"full/result.ccr","reportPath":"full/report.json","previousStepId":null},
|
||||
{"stepId":"delta-001","kind":"delta","validationTime":"2026-04-07T00:00:00Z","cirPath":"delta-001/input.cir","ccrPath":"delta-001/result.ccr","reportPath":"delta-001/report.json","previousStepId":"full"},
|
||||
|
||||
Reference in New Issue
Block a user