From 754b6f48af0c70a869937ea4dec3fbd1a620468c Mon Sep 17 00:00:00 2001 From: mohammad-starkware <130282237+MohammadNassar1@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:57:33 +0200 Subject: [PATCH] test(mempool): imp test-get-txs-returns-only-priority-txs (#1793) --- crates/mempool/src/mempool_test.rs | 18 ++++++++++++++++-- .../src/transaction_queue_test_utils.rs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index 0cc54f4aee..00d8f0f71a 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -87,11 +87,11 @@ impl MempoolContentBuilder { self } - fn _with_pending_queue(mut self, queue_txs: Q) -> Self + fn with_pending_queue(mut self, queue_txs: Q) -> Self where Q: IntoIterator, { - self.tx_queue_content_builder = self.tx_queue_content_builder._with_pending(queue_txs); + self.tx_queue_content_builder = self.tx_queue_content_builder.with_pending(queue_txs); self } @@ -218,6 +218,20 @@ fn test_get_txs_returns_by_priority_order(#[case] n_requested_txs: usize) { mempool_content.assert_eq(&mempool); } +#[rstest] +fn test_get_txs_does_not_return_pending_txs() { + // Setup. + let tx = tx!(); + + let mut mempool = MempoolContentBuilder::new() + .with_pending_queue([TransactionReference::new(&tx)]) + .with_pool([tx]) + .build_into_mempool(); + + // Test and assert. + get_txs_and_assert_expected(&mut mempool, 1, &[]); +} + #[rstest] fn test_get_txs_does_not_remove_returned_txs_from_pool() { // Setup. diff --git a/crates/mempool/src/transaction_queue_test_utils.rs b/crates/mempool/src/transaction_queue_test_utils.rs index 38dcf993ad..5cef7f2396 100644 --- a/crates/mempool/src/transaction_queue_test_utils.rs +++ b/crates/mempool/src/transaction_queue_test_utils.rs @@ -79,7 +79,7 @@ impl TransactionQueueContentBuilder { self } - pub fn _with_pending

(mut self, pending_txs: P) -> Self + pub fn with_pending

(mut self, pending_txs: P) -> Self where P: IntoIterator, {