Skip to content

Commit

Permalink
test with storage
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Sep 5, 2024
1 parent e969a9a commit 53a2d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 9 additions & 7 deletions hdp/src/provider/starknet/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ mod tests {

#[tokio::test]
async fn test_get_100_range_storage_with_proof() {
// TODO: why the storage proof returns same value as account proof
let target_block_start = 56400;
let target_block_end = 56401;
let target_block_end = 56500;
let target_block_range = (target_block_start..=target_block_end).collect::<Vec<u64>>();
let provider = test_provider();
let proof = provider
Expand All @@ -228,22 +227,25 @@ mod tests {

assert_eq!(proof.len(), target_block_range.len());
let output = proof.get(&target_block_start).unwrap();
println!("Proof: {:?}", output);

assert_eq!(
output.state_commitment.unwrap(),
Felt::from_str("0x26da0f5f0849cf69b4872ef5dced3ec68ce28c5e3f53207280113abb7feb158")
Felt::from_str("0x598cf91d9a3a7176d01926e8442b8bd83299168f723cb2d52080e895400d9a1")
.unwrap()
);

assert_eq!(output.contract_proof.len(), 23);
assert_eq!(output.contract_proof.len(), 17);

assert_eq!(
output.class_commitment.unwrap(),
Felt::from_str("0x46c1a0374b8ccf8d928e62ef40974304732c8a28f10b2c494adfabfcff0fa0a")
Felt::from_str("0x324d06b207f2891ef395ba1e7a0ef92b61a5772a294a289362dc37b0469c453")
.unwrap()
);

assert!(output.contract_data.is_none());
assert_eq!(
output.contract_data.clone().unwrap().storage_proofs[0].len(),
5
);
}

#[tokio::test]
Expand Down
8 changes: 3 additions & 5 deletions hdp/src/provider/starknet/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use starknet_types_core::{felt::Felt, hash::StarkHash};

/// Holds the membership/non-membership of a contract and its associated
/// contract contract if the contract exists.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[skip_serializing_none]
pub struct GetProofOutput {
/// The global state commitment for Starknet 0.11.0 blocks onwards, if
Expand All @@ -25,8 +25,6 @@ pub struct GetProofOutput {

/// Additional contract data if it exists.
pub contract_data: Option<ContractData>,

pub storage_proofs: Option<Vec<Vec<TrieNode>>>,
}

/// A node in a Starknet patricia-merkle trie.
Expand Down Expand Up @@ -65,7 +63,7 @@ impl TrieNode {
}

/// Holds the data and proofs for a specific contract.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContractData {
/// Required to verify the contract state hash to contract root calculation.
class_hash: Felt,
Expand All @@ -80,5 +78,5 @@ pub struct ContractData {
contract_state_hash_version: Felt,

/// The proofs associated with the queried storage values
storage_proofs: Vec<Vec<TrieNode>>,
pub storage_proofs: Vec<Vec<TrieNode>>,
}

0 comments on commit 53a2d65

Please sign in to comment.