From b04cbe2e27916f5f1d7e7e7514b9c6f59b6cdcb4 Mon Sep 17 00:00:00 2001 From: Ayelet Zilber Date: Thu, 19 Dec 2024 08:44:32 +0200 Subject: [PATCH] refactor(starknet_mempool): share code of queues combination in tests --- crates/starknet_mempool/src/mempool_test.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/starknet_mempool/src/mempool_test.rs b/crates/starknet_mempool/src/mempool_test.rs index 00084a5e37..f08e02661b 100644 --- a/crates/starknet_mempool/src/mempool_test.rs +++ b/crates/starknet_mempool/src/mempool_test.rs @@ -141,6 +141,14 @@ impl FromIterator 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, @@ -148,10 +156,7 @@ fn add_tx_and_verify_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); add_tx(&mut mempool, &valid_replacement_input); @@ -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(