Skip to content

Commit bf25b6c

Browse files
test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool state
1 parent f5a081b commit bf25b6c

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
@@ -46,7 +46,7 @@ impl MempoolState<FullState> {
4646
}
4747

4848
impl MempoolState<PartialState> {
49-
fn _with_pool<P>(pool_txs: P) -> Self
49+
fn with_pool<P>(pool_txs: P) -> Self
5050
where
5151
P: IntoIterator<Item = ThinTransaction>,
5252
{
@@ -300,17 +300,20 @@ fn test_new_with_duplicate_tx() {
300300

301301
#[rstest]
302302
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
303+
// Setup.
303304
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
304-
let same_input = input.clone();
305+
let duplicate_input = input.clone();
305306

307+
// Test.
306308
add_tx(&mut mempool, &input);
307-
308309
assert_matches!(
309-
mempool.add_tx(same_input.clone()),
310+
mempool.add_tx(duplicate_input),
310311
Err(MempoolError::DuplicateTransaction { .. })
311312
);
312-
// Assert that the original tx remains in the pool after the failed attempt.
313-
assert_eq_mempool_queue(&mempool, &[same_input.tx])
313+
314+
// Assert: the original transaction remains.
315+
let expected_mempool_state = MempoolState::with_pool([input.tx]);
316+
expected_mempool_state.assert_eq_pool_state(&mempool);
314317
}
315318

316319
#[rstest]

0 commit comments

Comments
 (0)