Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
fix declare V0 test
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun Jangra authored and Arun Jangra committed Jun 3, 2024
1 parent bd5dec7 commit 90951ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ where
.contract_class_by_class_hash(current_block_hash, txn.class_hash());

if let Some(contract_class) = contract_class {
log::error!("Contract class already exists: {:?}", contract_class);
log::debug!("Contract class already exists: {:?}", contract_class);
return Err(StarknetRpcApiError::ClassAlreadyDeclared);
}

Expand Down Expand Up @@ -343,8 +343,8 @@ where
StarknetRpcApiError::InternalServerError
})?;

let (txn_hash, class_hash) = self.declare_tx_common(declare_transaction).await.unwrap();

let (txn_hash, class_hash) = self.declare_tx_common(declare_transaction).await?;
Ok(DeclareV0Result { txn_hash, class_hash })
}
}
Expand Down
2 changes: 1 addition & 1 deletion starknet-rpc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env_logger = "0.9"
flate2 = { workspace = true }
indexmap = { workspace = true }
parity-scale-codec = { workspace = true }
reqwest = "0.11.18"
rstest = "0.18.1"
serde = "1.0.192"
serde_json = "1.0.108"
Expand All @@ -30,6 +29,7 @@ starknet_api = { workspace = true }
thiserror = { workspace = true }
tokio = { version = "1.36.0", features = ["rt", "macros", "parking_lot"] }
url = "2.4.1"
reqwest = { version = "0.11.22", features = ["json"] }

# [[test]]
# name = "starknet_spec_version"
Expand Down
10 changes: 8 additions & 2 deletions starknet-rpc-test/declareV0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde_json::json;
use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey};
use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointType};
use starknet_api::hash::{StarkFelt, StarkHash};
use starknet_api::transaction::{DeclareTransactionV0V1, Fee, TransactionSignature};
use starknet_api::transaction::{DeclareTransactionV0V1, Fee, TransactionHash, TransactionSignature};
use starknet_core::types::contract::legacy::LegacyContractClass;
use starknet_core::types::{BlockId, StarknetError};
use starknet_ff::FieldElement;
Expand All @@ -25,6 +25,12 @@ pub struct CustomDeclareV0Transaction {
pub abi_length: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DeclareV0Result {
pub txn_hash: TransactionHash,
pub class_hash: ClassHash,
}

#[rstest]
#[tokio::test]
async fn fail_non_existing_contract(madara: &ThreadSafeMadaraClient) -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -88,7 +94,7 @@ async fn declare_v0_contract(madara: &ThreadSafeMadaraClient) -> Result<(), anyh

match raw_txn_rpc {
Ok(val) => {
let res = val.json().await.unwrap();
let res = val.json::<DeclareV0Result>().await;
println!("Txn Sent Successfully : {:?}", res);
println!("Declare Success : {:?}", contract_abi_artifact.class_hash().unwrap());
}
Expand Down

0 comments on commit 90951ee

Please sign in to comment.