diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index ab1c90ae820566..21e1b643caf05e 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -790,7 +790,12 @@ mod tests { impl<'a> From<&'a TestCallbacks> for AccountLoader<'a, TestCallbacks> { fn from(callbacks: &'a TestCallbacks) -> AccountLoader<'a, TestCallbacks> { - AccountLoader::new(callbacks, None, ProgramCacheForTxBatch::default()) + AccountLoader::new_with_account_cache_capacity( + callbacks, + None, + ProgramCacheForTxBatch::default(), + 0, + ) } } @@ -1120,10 +1125,11 @@ mod tests { accounts_map, ..Default::default() }; - let mut account_loader = AccountLoader::new( + let mut account_loader = AccountLoader::new_with_account_cache_capacity( &callbacks, account_overrides, ProgramCacheForTxBatch::default(), + 0, ); load_transaction( &mut account_loader, @@ -1506,52 +1512,6 @@ mod tests { ); } - #[test] - fn test_load_transaction_accounts_program_account_not_found_but_loaded() { - let key1 = Keypair::new(); - let key2 = Keypair::new(); - - let message = Message { - account_keys: vec![key1.pubkey(), key2.pubkey()], - header: MessageHeader::default(), - instructions: vec![CompiledInstruction { - program_id_index: 1, - accounts: vec![0], - data: vec![], - }], - recent_blockhash: Hash::default(), - }; - - let sanitized_message = new_unchecked_sanitized_message(message); - let mut mock_bank = TestCallbacks::default(); - let mut account_data = AccountSharedData::default(); - account_data.set_lamports(200); - mock_bank.accounts_map.insert(key1.pubkey(), account_data); - - let mut error_metrics = TransactionErrorMetrics::default(); - let mut loaded_programs = ProgramCacheForTxBatch::default(); - loaded_programs.replenish(key2.pubkey(), Arc::new(ProgramCacheEntry::default())); - - let mut account_loader = AccountLoader::new(&mock_bank, None, loaded_programs); - - let sanitized_transaction = SanitizedTransaction::new_for_tests( - sanitized_message, - vec![Signature::new_unique()], - false, - ); - let result = load_transaction_accounts( - &mut account_loader, - sanitized_transaction.message(), - LoadedTransactionAccount::default(), - &ComputeBudgetLimits::default(), - &mut error_metrics, - &FeatureSet::default(), - &RentCollector::default(), - ); - - assert_eq!(result.err(), Some(TransactionError::ProgramAccountNotFound)); - } - // currently, the account loader retrieves read-only non-instruction accounts from the program cache // it creates a mock AccountSharedData with the executable flag set to true // however, it does not check whether these accounts are actually executable before doing so diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 0febe7e714669a..81a2ac4dc58d25 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -1219,7 +1219,12 @@ mod tests { impl<'a> From<&'a MockBankCallback> for AccountLoader<'a, MockBankCallback> { fn from(callbacks: &'a MockBankCallback) -> AccountLoader<'a, MockBankCallback> { - AccountLoader::new(callbacks, None, ProgramCacheForTxBatch::default()) + AccountLoader::new_with_account_cache_capacity( + callbacks, + None, + ProgramCacheForTxBatch::default(), + 0, + ) } } @@ -2489,66 +2494,6 @@ mod tests { } } - #[test] - fn test_validate_account_override_usage_on_validate_fee() { - /* - The test setups an account override with enough lamport to pass validate fee. - The account_db has the account with minimum rent amount thus would fail the validate_free. - The test verify that the override is used with a passing test of validate fee. - */ - let lamports_per_signature = 5000; - - let message = - new_unchecked_sanitized_message(Message::new(&[], Some(&Pubkey::new_unique()))); - - let fee_payer_address = message.fee_payer(); - let transaction_fee = lamports_per_signature; - let rent_collector = RentCollector::default(); - let min_balance = rent_collector.rent.minimum_balance(0); - - let fee_payer_account = AccountSharedData::new(min_balance, 0, &Pubkey::default()); - let mut mock_accounts = HashMap::new(); - mock_accounts.insert(*fee_payer_address, fee_payer_account.clone()); - - let necessary_balance = min_balance + transaction_fee; - let mut account_overrides = AccountOverrides::default(); - let fee_payer_account_override = - AccountSharedData::new(necessary_balance, 0, &Pubkey::default()); - account_overrides.set_account(fee_payer_address, Some(fee_payer_account_override)); - - let mock_bank = MockBankCallback { - account_shared_data: Arc::new(RwLock::new(mock_accounts)), - ..Default::default() - }; - let mut account_loader = AccountLoader::new( - &mock_bank, - Some(&account_overrides), - ProgramCacheForTxBatch::default(), - ); - - let mut error_counters = TransactionErrorMetrics::default(); - - 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: {:?}", - result.err() - ); - } - // Ensure `TransactionProcessingCallback::inspect_account()` is called when // validating the fee payer, since that's when the fee payer account is loaded. #[test]