Skip to content

Commit

Permalink
refactor(starknet_mempool): share code of queues combination in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeletstarkware committed Dec 19, 2024
1 parent 96ed6a5 commit b04cbe2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/starknet_mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,22 @@ impl FromIterator<AccountTransaction> for TransactionPool {
}
}

#[track_caller]
fn assert_valid_queue_combination(in_priority_queue: bool, in_pending_queue: bool) {
assert!(
!(in_priority_queue && in_pending_queue),
"A transaction can be in at most one queue at a time."
);
}

#[track_caller]
fn add_tx_and_verify_replacement(
mut mempool: Mempool,
valid_replacement_input: AddTransactionArgs,
in_priority_queue: bool,
in_pending_queue: bool,
) {
assert!(
!(in_priority_queue && in_pending_queue),
"A transaction can be in at most one queue at a time."
);
assert_valid_queue_combination(in_priority_queue, in_pending_queue);

add_tx(&mut mempool, &valid_replacement_input);

Expand Down Expand Up @@ -195,10 +200,7 @@ fn add_txs_and_verify_no_replacement(
in_priority_queue: bool,
in_pending_queue: bool,
) {
assert!(
!(in_priority_queue && in_pending_queue),
"A transaction can be in at most one queue at a time."
);
assert_valid_queue_combination(in_priority_queue, in_pending_queue);

for input in invalid_replacement_inputs {
add_tx_expect_error(
Expand Down

0 comments on commit b04cbe2

Please sign in to comment.