From 79d8089775586478ae3baf37ec42a01390875281 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware Date: Wed, 10 Jul 2024 16:02:04 +0300 Subject: [PATCH] fix: invalid nonce format commit-id:85a8a843 --- .../src/transaction/error_format_test.rs | 20 +++++++++++++++++-- crates/blockifier/src/transaction/errors.rs | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/blockifier/src/transaction/error_format_test.rs b/crates/blockifier/src/transaction/error_format_test.rs index 0dc6fb5fc0..02bbc28b47 100644 --- a/crates/blockifier/src/transaction/error_format_test.rs +++ b/crates/blockifier/src/transaction/error_format_test.rs @@ -1,9 +1,9 @@ use rstest::rstest; -use starknet_api::core::ClassHash; +use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::hash::StarkHash; use starknet_api::transaction::TransactionVersion; -use crate::transaction::errors::TransactionExecutionError; +use crate::transaction::errors::{TransactionExecutionError, TransactionPreValidationError}; #[rstest] fn test_contract_class_version_mismatch_format() { @@ -40,3 +40,19 @@ fn test_invalid_version_format() { "Transaction version 0x3 is not supported. Supported versions: [0x1, 0x2]." ); } + +#[rstest] +fn test_invalid_nounce_format() { + let error = TransactionPreValidationError::InvalidNonce { + address: ContractAddress(PatriciaKey::from(20_u8)), + account_nonce: Nonce(StarkHash::THREE), + incoming_tx_nonce: Nonce(StarkHash::TWO), + }; + assert_eq!( + error.to_string(), + "Invalid transaction nonce of contract at address \ + 0x0000000000000000000000000000000000000000000000000000000000000014. Account nonce: \ + 0x0000000000000000000000000000000000000000000000000000000000000003; got: \ + 0x0000000000000000000000000000000000000000000000000000000000000002." + ); +} diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index 0edbba53c5..70b9fbe6ab 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -114,8 +114,8 @@ pub enum TransactionExecutionError { #[derive(Debug, Error)] pub enum TransactionPreValidationError { #[error( - "Invalid transaction nonce of contract at address {address:?}. Account nonce: \ - {account_nonce:?}; got: {incoming_tx_nonce:?}." + "Invalid transaction nonce of contract at address {:#064x}. Account nonce: \ + {:#064x}; got: {:#064x}.", ***address, **account_nonce, **incoming_tx_nonce )] InvalidNonce { address: ContractAddress, account_nonce: Nonce, incoming_tx_nonce: Nonce }, #[error(transparent)]