From d1ed4147a0e71679d284d07a2f4341a7bed44f52 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 20c6be4054..97ff8346c9 100644 --- a/crates/blockifier/src/transaction/error_format_test.rs +++ b/crates/blockifier/src/transaction/error_format_test.rs @@ -1,8 +1,8 @@ -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}; #[test] fn test_contract_class_version_mismatch() { @@ -39,3 +39,19 @@ fn test_invalid_version_format() { "Transaction version 0x3 is not supported. Supported versions: [0x1, 0x2]." ); } + +#[test] +fn test_invalid_nonce_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)]