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(
|
||||
@@ -120,15 +122,15 @@ fn cir_replay_matrix_script_matches_reference_for_all_participants() {
|
||||
}
|
||||
|
||||
let td = tempfile::tempdir().expect("tempdir");
|
||||
let static_root = td.path().join("static");
|
||||
let repo_bytes_db = td.path().join("repo-bytes.db");
|
||||
let cir_path = td.path().join("sample.cir");
|
||||
let mirror_root = td.path().join("mirror");
|
||||
let out_dir = td.path().join("matrix-out");
|
||||
|
||||
let (cir, ta_bytes) = build_ta_only_cir();
|
||||
std::fs::write(&cir_path, encode_cir(&cir).expect("encode cir")).expect("write cir");
|
||||
write_static(&static_root, "20260407", &ta_bytes);
|
||||
materialize_cir(&cir, &static_root, &mirror_root, true).expect("materialize");
|
||||
write_repo_bytes(&repo_bytes_db, &ta_bytes);
|
||||
materialize_cir_from_repo_bytes(&cir, &repo_bytes_db, &mirror_root, true).expect("materialize");
|
||||
let reference_ccr = prepare_reference_ccr(td.path(), &cir, &mirror_root);
|
||||
|
||||
let script =
|
||||
@@ -146,8 +148,8 @@ fn cir_replay_matrix_script_matches_reference_for_all_participants() {
|
||||
.args([
|
||||
"--cir",
|
||||
cir_path.to_string_lossy().as_ref(),
|
||||
"--static-root",
|
||||
static_root.to_string_lossy().as_ref(),
|
||||
"--repo-bytes-db",
|
||||
repo_bytes_db.to_string_lossy().as_ref(),
|
||||
"--out-dir",
|
||||
out_dir.to_string_lossy().as_ref(),
|
||||
"--reference-ccr",
|
||||
|
||||
Reference in New Issue
Block a user