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

Commit

Permalink
fix: invalid nonce format
Browse files Browse the repository at this point in the history
commit-id:85a8a843
  • Loading branch information
AvivYossef-starkware committed Jul 14, 2024
1 parent 0662936 commit 2b421bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions crates/blockifier/src/transaction/error_format_test.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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."
);
}
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 2b421bb

Please sign in to comment.