diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 7aa0e305f4c489..73be7be5947383 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -3111,6 +3111,11 @@ fn test_filter_program_errors_and_collect_priority_fee() { ); } +// HANA NOTE the original version of this test means well but is unsound +// it seems like the idea is that in an entry the second tx should be invalid because the txes are *not serialized* +// but in reality the only reason it fails is because of locks. ie it would fail even if keypair had a balance +// on the other hand it is a perfectly valid simd83 batch because the first transaction funds the second +// i wanted to change rather than delete it tho since i dunno how much coverage the tx count functions have #[test] fn test_debits_before_credits() { let (genesis_config, mint_keypair) = @@ -3118,34 +3123,39 @@ fn test_debits_before_credits() { let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair = Keypair::new(); let tx0 = system_transaction::transfer( - &mint_keypair, - &keypair.pubkey(), - sol_to_lamports(2.), - genesis_config.hash(), - ); - let tx1 = system_transaction::transfer( &keypair, &mint_keypair.pubkey(), sol_to_lamports(1.), genesis_config.hash(), ); + let tx1 = system_transaction::transfer( + &mint_keypair, + &keypair.pubkey(), + sol_to_lamports(2.), + genesis_config.hash(), + ); let txs = vec![tx0, tx1]; let results = bank.process_transactions(txs.iter()); - assert!(results[1].is_err()); + assert!(results[0].is_err()); // Assert bad transactions aren't counted. assert_eq!(bank.transaction_count(), 1); assert_eq!(bank.non_vote_transaction_count_since_restart(), 1); } -#[test] -fn test_readonly_accounts() { +#[test_case(false; "old")] +#[test_case(true; "simd83")] +fn test_readonly_accounts(disable_intrabatch_account_locks: bool) { let GenesisConfigInfo { genesis_config, mint_keypair, .. } = create_genesis_config_with_leader(500, &solana_pubkey::new_rand(), 0); - let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); + let mut bank = Bank::new_for_tests(&genesis_config); + if !disable_intrabatch_account_locks { + bank.deactivate_feature(&feature_set::disable_intrabatch_account_locks::id()); + } + let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests(); let vote_pubkey0 = solana_pubkey::new_rand(); let vote_pubkey1 = solana_pubkey::new_rand(); @@ -3209,9 +3219,16 @@ fn test_readonly_accounts() { ); let txs = vec![tx0, tx1]; let results = bank.process_transactions(txs.iter()); - // However, an account may not be locked as read-only and writable at the same time. + // Whether an account can be locked as read-only and writable at the same time depends on features. assert_eq!(results[0], Ok(())); - assert_eq!(results[1], Err(TransactionError::AccountInUse)); + assert_eq!( + results[1], + if disable_intrabatch_account_locks { + Ok(()) + } else { + Err(TransactionError::AccountInUse) + } + ); } #[test] @@ -9451,8 +9468,9 @@ fn test_vote_epoch_panic() { ); } -#[test] -fn test_tx_log_order() { +#[test_case(false; "old")] +#[test_case(true; "simd83")] +fn test_tx_log_order(disable_intrabatch_account_locks: bool) { let GenesisConfigInfo { genesis_config, mint_keypair, @@ -9462,7 +9480,11 @@ fn test_tx_log_order() { &Pubkey::new_unique(), bootstrap_validator_stake_lamports(), ); - let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); + let mut bank = Bank::new_for_tests(&genesis_config); + if !disable_intrabatch_account_locks { + bank.deactivate_feature(&feature_set::disable_intrabatch_account_locks::id()); + } + let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests(); *bank.transaction_log_collector_config.write().unwrap() = TransactionLogCollectorConfig { mentioned_addresses: HashSet::new(), filter: TransactionLogCollectorFilter::All, @@ -9519,7 +9541,11 @@ fn test_tx_log_order() { .as_ref() .unwrap()[2] .contains(&"failed".to_string())); - assert!(commit_results[2].is_err()); + if disable_intrabatch_account_locks { + assert!(commit_results[2].is_ok()); + } else { + assert!(commit_results[2].is_err()); + } let stored_logs = &bank.transaction_log_collector.read().unwrap().logs; let success_log_info = stored_logs