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

Commit

Permalink
test(concurrency): test finish_execution_during_commit (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-starkware authored May 28, 2024
1 parent 5989a61 commit 8d94939
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions crates/blockifier/src/concurrency/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ impl Scheduler {
/// already scheduled.
pub fn finish_execution(&self, tx_index: TxIndex) {
self.set_executed_status(tx_index);
if self.validation_index.load(Ordering::Acquire) > tx_index {
self.decrease_validation_index(tx_index);
}
self.decrease_validation_index(tx_index);
}

pub fn try_validation_abort(&self, tx_index: TxIndex) -> bool {
Expand Down
15 changes: 15 additions & 0 deletions crates/blockifier/src/concurrency/scheduler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ fn test_commit_flow(
}
}

#[rstest]
#[case::reduces_validation_index(0, 3)]
#[case::does_not_reduce_validation_index(1, 0)]
fn test_finish_execution_during_commit(
#[case] tx_index: TxIndex,
#[case] validation_index: TxIndex,
) {
let target_index = tx_index + 1;
let scheduler =
default_scheduler!(chunk_size: DEFAULT_CHUNK_SIZE, validation_index: validation_index);
scheduler.finish_execution_during_commit(tx_index);
let expected_validation_index = min(target_index, validation_index);
assert_eq!(scheduler.validation_index.load(Ordering::Acquire), expected_validation_index);
}

#[rstest]
#[case::happy_flow(TransactionStatus::Executing)]
#[should_panic(expected = "Only executing transactions can gain status executed. Transaction 0 \
Expand Down

0 comments on commit 8d94939

Please sign in to comment.