Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(mempool): refactor test_tip_priority_over_tx_hash to use mempool… #446

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl MempoolState<PartialState> {
}
}

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 @@ -344,15 +344,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
Loading