Skip to content

Commit 4dca6f6

Browse files
test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool state
1 parent f1d94c0 commit 4dca6f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/mempool/src/mempool_test.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl MempoolState<FullState> {
4949
}
5050

5151
impl MempoolState<PartialState> {
52-
fn _with_pool<P>(pool_txs: P) -> Self
52+
fn with_pool<P>(pool_txs: P) -> Self
5353
where
5454
P: IntoIterator<Item = ThinTransaction>,
5555
{
@@ -305,17 +305,20 @@ fn test_new_with_duplicate_tx() {
305305

306306
#[rstest]
307307
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
308+
// Setup.
308309
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
309-
let same_input = input.clone();
310+
let duplicate_input = input.clone();
310311

312+
// Test.
311313
add_tx(&mut mempool, &input);
312-
313314
assert_matches!(
314-
mempool.add_tx(same_input.clone()),
315+
mempool.add_tx(duplicate_input),
315316
Err(MempoolError::DuplicateTransaction { .. })
316317
);
317-
// Assert that the original tx remains in the pool after the failed attempt.
318-
assert_eq_mempool_queue(&mempool, &[same_input.tx])
318+
319+
// Assert: the original transaction remains.
320+
let expected_mempool_state = MempoolState::with_pool([input.tx]);
321+
expected_mempool_state.assert_eq_pool_state(&mempool);
319322
}
320323

321324
#[rstest]

0 commit comments

Comments
 (0)