Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
chore(concurrency): fix the test test_finish_validation (#1993)
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-starkware committed Jun 18, 2024
1 parent c7e4ee3 commit 5129ccd
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions crates/blockifier/src/concurrency/scheduler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,39 +215,22 @@ fn test_try_validation_abort(#[case] tx_status: TransactionStatus) {
}

#[rstest]
#[case::not_aborted(0, 10, false)]
#[case::returns_execution_task(0, 10, true)]
#[case::does_not_return_execution_task(10, 0, true)]
fn test_finish_validation(
#[case] tx_index: TxIndex,
#[case] execution_index: TxIndex,
#[case] aborted: bool,
) {
#[case::returns_execution_task(0, 10)]
#[case::does_not_return_execution_task(10, 0)]
fn test_finish_abort(#[case] tx_index: TxIndex, #[case] execution_index: TxIndex) {
let scheduler = default_scheduler!(
chunk_size: DEFAULT_CHUNK_SIZE,
execution_index: execution_index,
);
let tx_status = if aborted { TransactionStatus::Aborting } else { TransactionStatus::Executed };
scheduler.set_tx_status(tx_index, tx_status);
let mut result = Task::NoTask;
if aborted {
result = scheduler.finish_abort(tx_index);
}
scheduler.set_tx_status(tx_index, TransactionStatus::Aborting);
let result = scheduler.finish_abort(tx_index);
let new_status = scheduler.lock_tx_status(tx_index);
match aborted {
true => {
if execution_index > tx_index {
assert_eq!(result, Task::ExecutionTask(tx_index));
assert_eq!(*new_status, TransactionStatus::Executing);
} else {
assert_eq!(result, Task::NoTask);
assert_eq!(*new_status, TransactionStatus::ReadyToExecute);
}
}
false => {
assert_eq!(result, Task::NoTask);
assert_eq!(*new_status, TransactionStatus::Executed);
}
if execution_index > tx_index {
assert_eq!(result, Task::ExecutionTask(tx_index));
assert_eq!(*new_status, TransactionStatus::Executing);
} else {
assert_eq!(result, Task::NoTask);
assert_eq!(*new_status, TransactionStatus::ReadyToExecute);
}
}

Expand Down

0 comments on commit 5129ccd

Please sign in to comment.