Skip to content

Commit

Permalink
fix: minor issues based on reviews and add tests for blocks with this…
Browse files Browse the repository at this point in the history
… issue.
  • Loading branch information
whichqua committed Oct 2, 2024
1 parent b5d131d commit 2005edc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/bin/prove_block/src/rpc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub(crate) async fn get_storage_proofs(

log::info!("Contracts we're fetching proofs for:");
for (contract_address, storage_keys) in accessed_keys_by_address {
log::info!(" {}", contract_address.to_string());
log::info!(" Fetching proof for {}", contract_address.to_string());
let contract_address_felt = *contract_address.key();
let storage_proof =
get_storage_proof_for_contract(client, contract_address, storage_keys.into_iter(), block_number).await?;
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/prove_block/tests/prove_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ use rstest::rstest;
#[case::dest_ptr_not_a_relocatable_2(155830)]
#[case::inconsistent_cairo0_class_hash_0(30000)]
#[case::inconsistent_cairo0_class_hash_1(204936)]
#[case::no_possible_convertion_1(155007)]
#[case::no_possible_convertion_2(155029)]
#[ignore = "Requires a running Pathfinder node"]
#[tokio::test(flavor = "multi_thread")]
async fn test_prove_selected_blocks(#[case] block_number: u64) {
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc-client/src/pathfinder/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum ClientError {
#[error("Encountered a request error: {0}")]
ReqwestError(#[from] reqwest::Error),
#[error("Encountered a custom error: {0}")]
Msg(String),
CustomError(String),
}

fn jsonrpc_request(method: &str, params: serde_json::Value) -> serde_json::Value {
Expand Down Expand Up @@ -47,7 +47,7 @@ async fn handle_error<T: DeserializeOwned>(response: Response) -> Result<T, Clie
StatusCode::OK => Ok(response.json().await?),
s => {
let error = response.text().await?;
Err(ClientError::Msg(format!("Received response: {s:?} Error: {error}")))
Err(ClientError::CustomError(format!("Received response: {s:?} Error: {error}")))
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions crates/starknet-os-types/src/sierra_contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ impl GenericSierraContractClass {
}

fn build_cairo_lang_class(&self) -> Result<CairoLangSierraContractClass, ContractClassError> {
match self.get_serialized_contract_class() {
Ok(serialized_class) => {
let contract_class = serde_json::from_slice(serialized_class)?;
Ok(contract_class)
}
Err(e) => Err(e),
}
self.get_serialized_contract_class().and_then(|res| {
let contract_class = serde_json::from_slice(res)?;
Ok(contract_class)
})
}

pub fn get_serialized_contract_class(&self) -> Result<&Vec<u8>, ContractClassError> {
Expand Down

0 comments on commit 2005edc

Please sign in to comment.