move cost model tests (#32034)
This commit is contained in:
parent
7cea6dd57c
commit
bfe171017c
|
@ -12424,42 +12424,6 @@ fn test_bank_verify_accounts_hash_with_base() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::field_reassign_with_default)]
|
|
||||||
#[test]
|
|
||||||
fn test_calculate_loaded_accounts_data_size_cost() {
|
|
||||||
let mut compute_budget = ComputeBudget::default();
|
|
||||||
|
|
||||||
// accounts data size are priced in block of 32K, ...
|
|
||||||
|
|
||||||
// ... requesting less than 32K should still be charged as one block
|
|
||||||
compute_budget.loaded_accounts_data_size_limit = 31_usize * 1024;
|
|
||||||
assert_eq!(
|
|
||||||
compute_budget.heap_cost,
|
|
||||||
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
|
||||||
);
|
|
||||||
|
|
||||||
// ... requesting exact 32K should be charged as one block
|
|
||||||
compute_budget.loaded_accounts_data_size_limit = 32_usize * 1024;
|
|
||||||
assert_eq!(
|
|
||||||
compute_budget.heap_cost,
|
|
||||||
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
|
||||||
);
|
|
||||||
|
|
||||||
// ... requesting slightly above 32K should be charged as 2 block
|
|
||||||
compute_budget.loaded_accounts_data_size_limit = 33_usize * 1024;
|
|
||||||
assert_eq!(
|
|
||||||
compute_budget.heap_cost * 2,
|
|
||||||
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
|
||||||
);
|
|
||||||
|
|
||||||
// ... requesting exact 64K should be charged as 2 block
|
|
||||||
compute_budget.loaded_accounts_data_size_limit = 64_usize * 1024;
|
|
||||||
assert_eq!(
|
|
||||||
compute_budget.heap_cost * 2,
|
|
||||||
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_squash_timing_add_assign() {
|
fn test_squash_timing_add_assign() {
|
||||||
let mut t0 = SquashTiming::default();
|
let mut t0 = SquashTiming::default();
|
||||||
|
|
|
@ -652,4 +652,40 @@ mod tests {
|
||||||
tx_cost.loaded_accounts_data_size_cost
|
tx_cost.loaded_accounts_data_size_cost
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::field_reassign_with_default)]
|
||||||
|
#[test]
|
||||||
|
fn test_calculate_loaded_accounts_data_size_cost() {
|
||||||
|
let mut compute_budget = ComputeBudget::default();
|
||||||
|
|
||||||
|
// accounts data size are priced in block of 32K, ...
|
||||||
|
|
||||||
|
// ... requesting less than 32K should still be charged as one block
|
||||||
|
compute_budget.loaded_accounts_data_size_limit = 31_usize * 1024;
|
||||||
|
assert_eq!(
|
||||||
|
compute_budget.heap_cost,
|
||||||
|
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
||||||
|
);
|
||||||
|
|
||||||
|
// ... requesting exact 32K should be charged as one block
|
||||||
|
compute_budget.loaded_accounts_data_size_limit = 32_usize * 1024;
|
||||||
|
assert_eq!(
|
||||||
|
compute_budget.heap_cost,
|
||||||
|
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
||||||
|
);
|
||||||
|
|
||||||
|
// ... requesting slightly above 32K should be charged as 2 block
|
||||||
|
compute_budget.loaded_accounts_data_size_limit = 33_usize * 1024;
|
||||||
|
assert_eq!(
|
||||||
|
compute_budget.heap_cost * 2,
|
||||||
|
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
||||||
|
);
|
||||||
|
|
||||||
|
// ... requesting exact 64K should be charged as 2 block
|
||||||
|
compute_budget.loaded_accounts_data_size_limit = 64_usize * 1024;
|
||||||
|
assert_eq!(
|
||||||
|
compute_budget.heap_cost * 2,
|
||||||
|
CostModel::calculate_loaded_accounts_data_size_cost(&compute_budget)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue