Skip to content

Commit 232db3d

Browse files
test(mempool): refactor test_tip_priority_over_tx_hash to use mempool state (#446)
1 parent a19df01 commit 232db3d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/mempool/src/mempool_test.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl MempoolState<PartialState> {
6060
}
6161
}
6262

63-
fn _with_queue<Q>(queue_txs: Q) -> Self
63+
fn with_queue<Q>(queue_txs: Q) -> Self
6464
where
6565
Q: IntoIterator<Item = TransactionReference>,
6666
{
@@ -347,15 +347,25 @@ fn test_add_tx_with_identical_tip_succeeds(mut mempool: Mempool) {
347347

348348
#[rstest]
349349
fn test_tip_priority_over_tx_hash(mut mempool: Mempool) {
350+
// Setup.
350351
let input_big_tip_small_hash = add_tx_input!(tip: 2, tx_hash: Felt::ONE);
351352

352353
// Create a transaction with identical tip, it should be allowed through since the priority
353354
// queue tie-breaks identical tips by other tx-unique identifiers (for example tx hash).
354355
let input_small_tip_big_hash = add_tx_input!(tip: 1, tx_hash: Felt::TWO, sender_address: "0x1");
355356

357+
// Test.
356358
add_tx(&mut mempool, &input_big_tip_small_hash);
357359
add_tx(&mut mempool, &input_small_tip_big_hash);
358-
assert_eq_mempool_queue(&mempool, &[input_big_tip_small_hash.tx, input_small_tip_big_hash.tx])
360+
361+
// Assert: ensure that the transaction with the higher tip is prioritized higher.
362+
let expected_queue_txs = [
363+
TransactionReference::new(&input_big_tip_small_hash.tx),
364+
TransactionReference::new(&input_small_tip_big_hash.tx),
365+
];
366+
let expected_mempool_state = MempoolState::with_queue(expected_queue_txs);
367+
368+
expected_mempool_state.assert_eq_queue_state(&mempool);
359369
}
360370

361371
#[rstest]

0 commit comments

Comments
 (0)