From 3ba164e6251ebc0f9762d0b172555c457d67a44d Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:03:43 +0300 Subject: [PATCH] fix: declare transaction error format (#2069) commit-id:5ae2b059 --- .../src/transaction/error_format_test.rs | 14 ++++++++++++++ crates/blockifier/src/transaction/errors.rs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/blockifier/src/transaction/error_format_test.rs b/crates/blockifier/src/transaction/error_format_test.rs index e90a760d90..844c884499 100644 --- a/crates/blockifier/src/transaction/error_format_test.rs +++ b/crates/blockifier/src/transaction/error_format_test.rs @@ -1,3 +1,5 @@ +use starknet_api::core::ClassHash; +use starknet_api::hash::StarkHash; use starknet_api::transaction::TransactionVersion; use crate::transaction::errors::TransactionExecutionError; @@ -13,3 +15,15 @@ fn test_contract_class_version_mismatch() { "Declare transaction version 1 must have a contract class of Cairo version 2." ); } + +#[test] +fn test_declare_transaction_error_format() { + let error = TransactionExecutionError::DeclareTransactionError { + class_hash: ClassHash(StarkHash::THREE), + }; + assert_eq!( + error.to_string(), + "Class with hash 0x0000000000000000000000000000000000000000000000000000000000000003 is \ + already declared." + ); +} diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index 051ae6c74f..30e050456e 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -59,7 +59,7 @@ pub enum TransactionExecutionError { String::from(gen_transaction_execution_error_trace(self)) )] ContractConstructorExecutionFailed(#[from] ConstructorEntryPointExecutionError), - #[error("Class with hash {class_hash:?} is already declared.")] + #[error("Class with hash {:#064x} is already declared.", **class_hash)] DeclareTransactionError { class_hash: ClassHash }, #[error( "Transaction execution has failed:\n{}",