From 5a772ba9f6e9ef532108f308cea270b096170d5e Mon Sep 17 00:00:00 2001 From: hana <81144685+2501babe@users.noreply.github.com> Date: Sun, 3 Nov 2024 22:11:22 -0800 Subject: [PATCH] use combined validation function for all tests --- svm/src/transaction_processor.rs | 227 ++++++++++++++++--------------- 1 file changed, 118 insertions(+), 109 deletions(-) diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 8eefe7891c4fa0..acf8763136f089 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -2041,18 +2041,20 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &rent_collector, - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &rent_collector, + &mut error_counters, + ); let post_validation_fee_payer_account = { let mut account = fee_payer_account.clone(); @@ -2118,18 +2120,20 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &rent_collector, - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &rent_collector, + &mut error_counters, + ); let post_validation_fee_payer_account = { let mut account = fee_payer_account.clone(); @@ -2168,18 +2172,20 @@ mod tests { let mock_bank = MockBankCallback::default(); let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &RentCollector::default(), - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &RentCollector::default(), + &mut error_counters, + ); assert_eq!(error_counters.account_not_found, 1); assert_eq!(result, Err(TransactionError::AccountNotFound)); @@ -2201,18 +2207,20 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &RentCollector::default(), - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &RentCollector::default(), + &mut error_counters, + ); assert_eq!(error_counters.insufficient_funds, 1); assert_eq!(result, Err(TransactionError::InsufficientFundsForFee)); @@ -2238,18 +2246,20 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &rent_collector, - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &rent_collector, + &mut error_counters, + ); assert_eq!( result, @@ -2273,18 +2283,20 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &RentCollector::default(), - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &RentCollector::default(), + &mut error_counters, + ); assert_eq!(error_counters.invalid_account_for_fee, 1); assert_eq!(result, Err(TransactionError::InvalidAccountForFee)); @@ -2304,18 +2316,20 @@ mod tests { let mock_bank = MockBankCallback::default(); let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &RentCollector::default(), - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &RentCollector::default(), + &mut error_counters, + ); assert_eq!(error_counters.invalid_compute_budget, 1); assert_eq!(result, Err(TransactionError::DuplicateInstruction(1u8))); @@ -2379,20 +2393,11 @@ mod tests { lamports_per_signature, }; - let result = TransactionBatchProcessor::::validate_transaction_nonce( - &mut account_loader, - &message, - &tx_details, - &environment_blockhash, - &mut error_counters, - ); - - assert_eq!(result, Ok(())); - - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( + let result = TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( &mut account_loader, &message, tx_details, + &environment_blockhash, &feature_set, &FeeStructure::default(), &rent_collector, @@ -2447,13 +2452,14 @@ mod tests { let mut account_loader = (&mock_bank).into(); let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( + let result = TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( &mut account_loader, &message, CheckedTransactionDetails { nonce: None, lamports_per_signature, }, + &Hash::default(), &feature_set, &FeeStructure::default(), &rent_collector, @@ -2504,18 +2510,20 @@ mod tests { let mut error_counters = TransactionErrorMetrics::default(); - let result = TransactionBatchProcessor::::validate_transaction_fee_payer( - &mut account_loader, - &message, - CheckedTransactionDetails { - nonce: None, - lamports_per_signature, - }, - &FeatureSet::default(), - &FeeStructure::default(), - &rent_collector, - &mut error_counters, - ); + let result = + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( + &mut account_loader, + &message, + CheckedTransactionDetails { + nonce: None, + lamports_per_signature, + }, + &Hash::default(), + &FeatureSet::default(), + &FeeStructure::default(), + &rent_collector, + &mut error_counters, + ); assert!( result.is_ok(), "test_account_override_used: {:?}", @@ -2550,13 +2558,14 @@ mod tests { Some(&fee_payer_address), &Hash::new_unique(), )); - TransactionBatchProcessor::::validate_transaction_fee_payer( + TransactionBatchProcessor::::validate_transaction_nonce_and_fee_payer( &mut account_loader, &message, CheckedTransactionDetails { nonce: None, lamports_per_signature: 5000, }, + &Hash::default(), &FeatureSet::default(), &FeeStructure::default(), &RentCollector::default(),