Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk committed Sep 30, 2024
1 parent aebcfc7 commit 9d876e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/trie/common/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ impl StorageProof {
Self { key, nibbles, ..Default::default() }
}

/// Set proof nodes on storage proof.
pub fn with_proof(mut self, proof: Vec<Bytes>) -> Self {
self.proof = proof;
self
}

/// Verify the proof against the provided storage root.
pub fn verify(&self, root: B256) -> Result<(), ProofVerificationError> {
let expected =
Expand Down
6 changes: 5 additions & 1 deletion crates/trie/db/tests/proof.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(missing_docs)]

use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
use alloy_rlp::EMPTY_STRING_CODE;
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET};
use reth_primitives::{constants::EMPTY_ROOT_HASH, Account};
use reth_provider::test_utils::{create_test_provider_factory, insert_genesis};
Expand Down Expand Up @@ -111,7 +112,10 @@ fn testspec_empty_storage_proof() {
assert_eq!(slots.len(), account_proof.storage_proofs.len());
for (idx, slot) in slots.into_iter().enumerate() {
let proof = account_proof.storage_proofs.get(idx).unwrap();
assert_eq!(proof, &StorageProof::new(slot));
assert_eq!(
proof,
&StorageProof::new(slot).with_proof(vec![Bytes::from([EMPTY_STRING_CODE])])
);
assert_eq!(proof.verify(account_proof.storage_root), Ok(()));
}
assert_eq!(account_proof.verify(root), Ok(()));
Expand Down

0 comments on commit 9d876e2

Please sign in to comment.