fix tests

This commit is contained in:
Peter Zhang 2025-09-08 16:27:28 +08:00
parent 4a8479e0df
commit 382661ec98
2 changed files with 3 additions and 13 deletions

View File

@ -85,26 +85,16 @@ fn test_put_get() {
.unwrap(); .unwrap();
assert_eq!(chunk_with_proof.chunk, chunk_array.chunk_at(i).unwrap()); assert_eq!(chunk_with_proof.chunk, chunk_array.chunk_at(i).unwrap());
// Create an H256 merkle tree for proof comparison
let mut h256_merkle = AppendMerkleTree::<OptionalHash, Sha3Algorithm>::new(vec![], 0, None);
h256_merkle.append_list(
data_to_merkle_leaves(&LogManager::padding_raw(start_offset - 1)).unwrap(),
);
h256_merkle.append_list(data_to_merkle_leaves(&data_padded).unwrap());
assert_eq!( assert_eq!(
chunk_with_proof.proof, chunk_with_proof.proof,
AppendMerkleTree::convert_proof_to_h256( merkle.gen_proof_h256(i + start_offset).unwrap()
h256_merkle.gen_proof(i + start_offset).unwrap()
)
.unwrap()
); );
let r = chunk_with_proof.proof.validate::<Sha3Algorithm>( let r = chunk_with_proof.proof.validate::<Sha3Algorithm>(
&Sha3Algorithm::leaf(&chunk_with_proof.chunk.0), &Sha3Algorithm::leaf(&chunk_with_proof.chunk.0),
i + start_offset, i + start_offset,
); );
assert!(r.is_ok(), "proof={:?} \n r={:?}", chunk_with_proof.proof, r); assert!(r.is_ok(), "proof={:?} \n r={:?}", chunk_with_proof.proof, r);
assert!(h256_merkle.check_root(&chunk_with_proof.proof.root().into())); assert!(merkle.check_root(&chunk_with_proof.proof.root().into()));
} }
for i in (0..chunk_count).step_by(PORA_CHUNK_SIZE / 3) { for i in (0..chunk_count).step_by(PORA_CHUNK_SIZE / 3) {
let end = std::cmp::min(i + PORA_CHUNK_SIZE, chunk_count); let end = std::cmp::min(i + PORA_CHUNK_SIZE, chunk_count);

View File

@ -6,7 +6,7 @@ use crate::log_store::log_manager::{
use crate::log_store::metrics; use crate::log_store::metrics;
use crate::{try_option, LogManager, ZgsKeyValueDB}; use crate::{try_option, LogManager, ZgsKeyValueDB};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use append_merkle::{AppendMerkleTree, MerkleTreeRead, OptionalHash, Sha3Algorithm}; use append_merkle::{AppendMerkleTree, OptionalHash, Sha3Algorithm};
use ethereum_types::H256; use ethereum_types::H256;
use merkle_light::merkle::log2_pow2; use merkle_light::merkle::log2_pow2;
use shared_types::{DataRoot, Transaction}; use shared_types::{DataRoot, Transaction};