Skip to content

Commit

Permalink
test(mempool): imp test-get-txs-returns-only-priority-txs (#1793)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 authored Nov 5, 2024
1 parent 64e1d17 commit 754b6f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ impl MempoolContentBuilder {
self
}

fn _with_pending_queue<Q>(mut self, queue_txs: Q) -> Self
fn with_pending_queue<Q>(mut self, queue_txs: Q) -> Self
where
Q: IntoIterator<Item = TransactionReference>,
{
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
}

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/mempool/src/transaction_queue_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl TransactionQueueContentBuilder {
self
}

pub fn _with_pending<P>(mut self, pending_txs: P) -> Self
pub fn with_pending<P>(mut self, pending_txs: P) -> Self
where
P: IntoIterator<Item = TransactionReference>,
{
Expand Down

0 comments on commit 754b6f4

Please sign in to comment.