Skip to content

Commit

Permalink
Add test_read_transaction_status_with_old_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Oct 4, 2023
1 parent d79b8ba commit a12e45e
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down

0 comments on commit a12e45e

Please sign in to comment.