|
1 | 1 | #![cfg(test)]
|
2 | 2 | use {
|
| 3 | + assert_matches::assert_matches, |
3 | 4 | solana_compute_budget::compute_budget_limits::MAX_BUILTIN_ALLOCATION_COMPUTE_UNIT_LIMIT,
|
4 | 5 | solana_cost_model::cost_model::CostModel,
|
5 | 6 | solana_runtime::{bank::Bank, bank_forks::BankForks},
|
@@ -230,19 +231,20 @@ fn test_builtin_ix_cost_adjustment_with_cu_limit_too_low() {
|
230 | 231 | // Cost model & Compute budget: reserve/allocate requested CU Limit `1`
|
231 | 232 | // VM Execution: consume `1` CU, then fail
|
232 | 233 | // Result: 0 adjustment
|
233 |
| - let expected = TestResult { |
234 |
| - cost_adjustment: 0, |
235 |
| - execution_status: Err(TransactionError::InstructionError( |
236 |
| - 0, |
237 |
| - InstructionError::ComputationalBudgetExceeded, |
238 |
| - )), |
239 |
| - }; |
240 |
| - assert_eq!( |
241 |
| - expected, |
| 234 | + assert_matches!( |
242 | 235 | test_setup.execute_test_transaction(&[
|
243 | 236 | test_setup.transfer_ix(),
|
244 | 237 | test_setup.set_cu_limit_ix(cu_limit),
|
245 |
| - ]) |
| 238 | + ]), |
| 239 | + TestResult { |
| 240 | + cost_adjustment: 0, |
| 241 | + execution_status: Err(TransactionError::InstructionError( |
| 242 | + 0, |
| 243 | + InstructionError::ComputationalBudgetExceeded, |
| 244 | + None, |
| 245 | + Some(ii), |
| 246 | + )), |
| 247 | + } if ii > 0 |
246 | 248 | );
|
247 | 249 | }
|
248 | 250 |
|
@@ -282,16 +284,17 @@ fn test_builtin_ix_cost_adjustment_with_memo_no_cu_limit() {
|
282 | 284 | // (3_000 + 200_000) = 203_000 CUs (note: less than memo_ix needs)
|
283 | 285 | // VM Execution: consume all allocated CUs, then fail
|
284 | 286 | // Result: no adjustment
|
285 |
| - let expected = TestResult { |
286 |
| - cost_adjustment: 0, |
287 |
| - execution_status: Err(TransactionError::InstructionError( |
288 |
| - 1, |
289 |
| - InstructionError::ProgramFailedToComplete, |
290 |
| - )), |
291 |
| - }; |
292 |
| - assert_eq!( |
293 |
| - expected, |
294 |
| - test_setup.execute_test_transaction(&[test_setup.transfer_ix(), memo_ix.clone()],) |
| 287 | + assert_matches!( |
| 288 | + test_setup.execute_test_transaction(&[test_setup.transfer_ix(), memo_ix.clone()],), |
| 289 | + TestResult { |
| 290 | + cost_adjustment: 0, |
| 291 | + execution_status: Err(TransactionError::InstructionError( |
| 292 | + 1, |
| 293 | + InstructionError::ProgramFailedToComplete, |
| 294 | + None, |
| 295 | + Some(ii), |
| 296 | + )), |
| 297 | + } if ii > 0 |
295 | 298 | );
|
296 | 299 | }
|
297 | 300 |
|
|
0 commit comments