Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Add tx-index checks to test_rebatch_transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Jun 17, 2022
1 parent 790bf8c commit f07899b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4105,6 +4105,8 @@ pub mod tests {
let pubkey = solana_sdk::pubkey::new_rand();
let keypair2 = Keypair::new();
let pubkey2 = solana_sdk::pubkey::new_rand();
let keypair3 = Keypair::new();
let pubkey3 = solana_sdk::pubkey::new_rand();

let txs = vec![
SanitizedTransaction::from_transaction_for_tests(system_transaction::transfer(
Expand All @@ -4119,22 +4121,40 @@ pub mod tests {
1,
genesis_config.hash(),
)),
SanitizedTransaction::from_transaction_for_tests(system_transaction::transfer(
&keypair3,
&pubkey3,
1,
genesis_config.hash(),
)),
];

let batch = bank.prepare_sanitized_batch(&txs);
assert!(batch.needs_unlock());
let transaction_indexes = vec![0, 1];
let transaction_indexes = vec![42, 43, 44];

let batch2 = rebatch_transactions(
batch.lock_results(),
&bank,
batch.sanitized_transactions(),
0,
1,
0,
&transaction_indexes,
);
assert!(batch.needs_unlock());
assert!(!batch2.batch.needs_unlock());
assert_eq!(batch2.transaction_indexes, vec![42]);

let batch3 = rebatch_transactions(
batch.lock_results(),
&bank,
batch.sanitized_transactions(),
1,
2,
&transaction_indexes,
);
assert!(!batch3.batch.needs_unlock());
assert_eq!(batch3.transaction_indexes, vec![43, 44]);
}

#[test]
Expand Down

0 comments on commit f07899b

Please sign in to comment.