Skip to content

Commit e3c0b2f

Browse files
committed
fix rest of bank tests
1 parent 36f57af commit e3c0b2f

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

runtime/src/bank/tests.rs

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,41 +3111,51 @@ fn test_filter_program_errors_and_collect_priority_fee() {
31113111
);
31123112
}
31133113

3114+
// HANA NOTE the original version of this test means well but is unsound
3115+
// it seems like the idea is that in an entry the second tx should be invalid because the txes are *not serialized*
3116+
// but in reality the only reason it fails is because of locks. ie it would fail even if keypair had a balance
3117+
// on the other hand it is a perfectly valid simd83 batch because the first transaction funds the second
3118+
// i wanted to change rather than delete it tho since i dunno how much coverage the tx count functions have
31143119
#[test]
31153120
fn test_debits_before_credits() {
31163121
let (genesis_config, mint_keypair) =
31173122
create_genesis_config_no_tx_fee_no_rent(sol_to_lamports(2.));
31183123
let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
31193124
let keypair = Keypair::new();
31203125
let tx0 = system_transaction::transfer(
3121-
&mint_keypair,
3122-
&keypair.pubkey(),
3123-
sol_to_lamports(2.),
3124-
genesis_config.hash(),
3125-
);
3126-
let tx1 = system_transaction::transfer(
31273126
&keypair,
31283127
&mint_keypair.pubkey(),
31293128
sol_to_lamports(1.),
31303129
genesis_config.hash(),
31313130
);
3131+
let tx1 = system_transaction::transfer(
3132+
&mint_keypair,
3133+
&keypair.pubkey(),
3134+
sol_to_lamports(2.),
3135+
genesis_config.hash(),
3136+
);
31323137
let txs = vec![tx0, tx1];
31333138
let results = bank.process_transactions(txs.iter());
3134-
assert!(results[1].is_err());
3139+
assert!(results[0].is_err());
31353140

31363141
// Assert bad transactions aren't counted.
31373142
assert_eq!(bank.transaction_count(), 1);
31383143
assert_eq!(bank.non_vote_transaction_count_since_restart(), 1);
31393144
}
31403145

3141-
#[test]
3142-
fn test_readonly_accounts() {
3146+
#[test_case(false; "old")]
3147+
#[test_case(true; "simd83")]
3148+
fn test_readonly_accounts(disable_intrabatch_account_locks: bool) {
31433149
let GenesisConfigInfo {
31443150
genesis_config,
31453151
mint_keypair,
31463152
..
31473153
} = create_genesis_config_with_leader(500, &solana_pubkey::new_rand(), 0);
3148-
let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
3154+
let mut bank = Bank::new_for_tests(&genesis_config);
3155+
if !disable_intrabatch_account_locks {
3156+
bank.deactivate_feature(&feature_set::disable_intrabatch_account_locks::id());
3157+
}
3158+
let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests();
31493159

31503160
let vote_pubkey0 = solana_pubkey::new_rand();
31513161
let vote_pubkey1 = solana_pubkey::new_rand();
@@ -3209,9 +3219,16 @@ fn test_readonly_accounts() {
32093219
);
32103220
let txs = vec![tx0, tx1];
32113221
let results = bank.process_transactions(txs.iter());
3212-
// However, an account may not be locked as read-only and writable at the same time.
3222+
// Whether an account can be locked as read-only and writable at the same time depends on features.
32133223
assert_eq!(results[0], Ok(()));
3214-
assert_eq!(results[1], Err(TransactionError::AccountInUse));
3224+
assert_eq!(
3225+
results[1],
3226+
if disable_intrabatch_account_locks {
3227+
Ok(())
3228+
} else {
3229+
Err(TransactionError::AccountInUse)
3230+
}
3231+
);
32153232
}
32163233

32173234
#[test]
@@ -9451,8 +9468,9 @@ fn test_vote_epoch_panic() {
94519468
);
94529469
}
94539470

9454-
#[test]
9455-
fn test_tx_log_order() {
9471+
#[test_case(false; "old")]
9472+
#[test_case(true; "simd83")]
9473+
fn test_tx_log_order(disable_intrabatch_account_locks: bool) {
94569474
let GenesisConfigInfo {
94579475
genesis_config,
94589476
mint_keypair,
@@ -9462,7 +9480,11 @@ fn test_tx_log_order() {
94629480
&Pubkey::new_unique(),
94639481
bootstrap_validator_stake_lamports(),
94649482
);
9465-
let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);
9483+
let mut bank = Bank::new_for_tests(&genesis_config);
9484+
if !disable_intrabatch_account_locks {
9485+
bank.deactivate_feature(&feature_set::disable_intrabatch_account_locks::id());
9486+
}
9487+
let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests();
94669488
*bank.transaction_log_collector_config.write().unwrap() = TransactionLogCollectorConfig {
94679489
mentioned_addresses: HashSet::new(),
94689490
filter: TransactionLogCollectorFilter::All,
@@ -9519,7 +9541,11 @@ fn test_tx_log_order() {
95199541
.as_ref()
95209542
.unwrap()[2]
95219543
.contains(&"failed".to_string()));
9522-
assert!(commit_results[2].is_err());
9544+
if disable_intrabatch_account_locks {
9545+
assert!(commit_results[2].is_ok());
9546+
} else {
9547+
assert!(commit_results[2].is_err());
9548+
}
95239549

95249550
let stored_logs = &bank.transaction_log_collector.read().unwrap().logs;
95259551
let success_log_info = stored_logs

0 commit comments

Comments
 (0)