Skip to content

Commit

Permalink
test_cost_model_demoted_write_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Jan 19, 2024
1 parent 6835e10 commit 2fd136a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,22 @@ mod tests {
assert_eq!(0, tx_cost.data_bytes_cost);
}

#[test]
fn test_cost_model_demoted_write_lock() {
let (mint_keypair, start_hash) = test_setup();

// Cannot write-lock the system program, it will be demoted when taking locks.
// However, the cost should be calculated as if it were taken.
let simple_transaction = SanitizedTransaction::from_transaction_for_tests(
system_transaction::transfer(&mint_keypair, &system_program::id(), 2, start_hash),
);

// Cost should be fore 2 write-locks, but only 1 is actually writable.
let tx_cost = CostModel::calculate_cost(&simple_transaction, &FeatureSet::all_enabled());
assert_eq!(2 * WRITE_LOCK_UNITS, tx_cost.write_lock_cost());
assert_eq!(1, tx_cost.writable_accounts().len());
}

#[test]
fn test_cost_model_compute_budget_transaction() {
let (mint_keypair, start_hash) = test_setup();
Expand Down

0 comments on commit 2fd136a

Please sign in to comment.