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

Commit

Permalink
fix: contract class version mismatch format (#2082)
Browse files Browse the repository at this point in the history
commit-id:2978d6d0
  • Loading branch information
AvivYossef-starkware authored Jul 14, 2024
1 parent 7e87236 commit 8f09ea1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/blockifier/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub const TEST_ERC20_CONTRACT_CLASS_HASH: &str = "0x1010";
pub const ERC20_CONTRACT_PATH: &str = "./ERC20/ERC20_Cairo0/ERC20_without_some_syscalls/ERC20/\
erc20_contract_without_some_syscalls_compiled.json";

// TODO(Aviv, 14/7/2024): Move from test utils module, and use it in ContractClassVersionMismatch
// error.
#[derive(Clone, Copy, Debug)]
pub enum CairoVersion {
Cairo0,
Expand Down
2 changes: 2 additions & 0 deletions crates/blockifier/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod account_transaction;
pub mod constants;
#[cfg(test)]
pub mod error_format_test;
pub mod errors;
pub mod objects;
#[cfg(any(feature = "testing", test))]
Expand Down
15 changes: 15 additions & 0 deletions crates/blockifier/src/transaction/error_format_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use starknet_api::transaction::TransactionVersion;

use crate::transaction::errors::TransactionExecutionError;

#[test]
fn test_contract_class_version_mismatch() {
let error = TransactionExecutionError::ContractClassVersionMismatch {
declare_version: TransactionVersion::ONE,
cairo_version: 2,
};
assert_eq!(
error.to_string(),
"Declare transaction version 1 must have a contract class of Cairo version 2."
);
}
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub enum TransactionFeeError {
#[derive(Debug, Error)]
pub enum TransactionExecutionError {
#[error(
"Declare transaction version {declare_version:?} must have a contract class of Cairo \
version {cairo_version:?}."
"Declare transaction version {} must have a contract class of Cairo \
version {cairo_version:?}.", **declare_version
)]
ContractClassVersionMismatch { declare_version: TransactionVersion, cairo_version: u64 },
#[error(
Expand Down

0 comments on commit 8f09ea1

Please sign in to comment.