Skip to content

Commit

Permalink
test(mempool): refactor test_tip_priority_over_tx_hash to use mempool…
Browse files Browse the repository at this point in the history
… state
  • Loading branch information
ayeletstarkware committed Jul 24, 2024
1 parent f5a081b commit d91ace9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl MempoolState<PartialState> {
Self { tx_pool: Some(pool_txs.into_iter().collect()), ..Default::default() }
}

fn _with_queue<Q>(queue_txs: Q) -> Self
fn with_queue<Q>(queue_txs: Q) -> Self
where
Q: IntoIterator<Item = TransactionReference>,
{
Expand Down Expand Up @@ -339,15 +339,25 @@ fn test_add_tx_with_identical_tip_succeeds(mut mempool: Mempool) {

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

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

// Test.
add_tx(&mut mempool, &input_big_tip_small_hash);
add_tx(&mut mempool, &input_small_tip_big_hash);
assert_eq_mempool_queue(&mempool, &[input_big_tip_small_hash.tx, input_small_tip_big_hash.tx])

// Assert: ensure that the transaction with the higher tip is prioritized higher.
let expected_queue_txs = [
TransactionReference::new(&input_big_tip_small_hash.tx),
TransactionReference::new(&input_small_tip_big_hash.tx),
];
let expected_mempool_state = MempoolState::with_queue(expected_queue_txs);

expected_mempool_state.assert_eq_queue_state(&mempool);
}

#[rstest]
Expand Down

0 comments on commit d91ace9

Please sign in to comment.