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

fix: invalid nonce format #2073

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading