From a12e45ec61c486924d752d213cf45dd43a84b852 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 3 Oct 2023 18:51:04 -0600 Subject: [PATCH] Add test_read_transaction_status_with_old_data --- ledger/src/blockstore.rs | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index a16b5fed035fc4..b099ce1f0f3fc9 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -7591,6 +7591,76 @@ pub mod tests { assert_eq!(compute_units_consumed, compute_units_consumed_2); } + #[test] + fn test_read_transaction_status_with_old_data() { + let ledger_path = get_tmp_ledger_path_auto_delete!(); + let blockstore = Blockstore::open(ledger_path.path()).unwrap(); + let signature = Signature::from([1; 64]); + + let index0_slot = 2; + blockstore + .write_deprecated_transaction_status( + 0, + index0_slot, + signature, + vec![&Pubkey::new_unique()], + vec![&Pubkey::new_unique()], + TransactionStatusMeta { + fee: index0_slot * 1_000, + ..TransactionStatusMeta::default() + }, + ) + .unwrap(); + + let index1_slot = 1; + blockstore + .write_deprecated_transaction_status( + 1, + index1_slot, + signature, + vec![&Pubkey::new_unique()], + vec![&Pubkey::new_unique()], + TransactionStatusMeta { + fee: index1_slot * 1_000, + ..TransactionStatusMeta::default() + }, + ) + .unwrap(); + + let slot = 3; + blockstore + .write_transaction_status( + slot, + signature, + vec![&Pubkey::new_unique()], + vec![&Pubkey::new_unique()], + TransactionStatusMeta { + fee: slot * 1_000, + ..TransactionStatusMeta::default() + }, + 0, + ) + .unwrap(); + + let meta = blockstore + .read_transaction_status((signature, slot)) + .unwrap() + .unwrap(); + assert_eq!(meta.fee, slot * 1000); + + let meta = blockstore + .read_transaction_status((signature, index0_slot)) + .unwrap() + .unwrap(); + assert_eq!(meta.fee, index0_slot * 1000); + + let meta = blockstore + .read_transaction_status((signature, index1_slot)) + .unwrap() + .unwrap(); + assert_eq!(meta.fee, index1_slot * 1000); + } + #[test] fn test_get_transaction_status() { let ledger_path = get_tmp_ledger_path_auto_delete!();