Skip to content

Commit 47a7c76

Browse files
test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool state
1 parent 00b48c5 commit 47a7c76

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
@@ -50,7 +50,7 @@ impl Default for MempoolState<PartialState> {
5050
}
5151

5252
impl MempoolState<PartialState> {
53-
fn _with_pool<P>(pool_txs: P) -> Self
53+
fn with_pool<P>(pool_txs: P) -> Self
5454
where
5555
P: IntoIterator<Item = ThinTransaction>,
5656
{
@@ -298,17 +298,20 @@ fn test_new_with_duplicate_tx() {
298298

299299
#[rstest]
300300
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
301+
// Setup
301302
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
302-
let same_input = input.clone();
303+
let duplicate_input = input.clone();
303304

305+
// Test: assert that the duplicate tx is not added to the mempool.
304306
add_tx(&mut mempool, &input);
305-
306307
assert_matches!(
307-
mempool.add_tx(same_input.clone()),
308+
mempool.add_tx(duplicate_input),
308309
Err(MempoolError::DuplicateTransaction { .. })
309310
);
310-
// Assert that the original tx remains in the pool after the failed attempt.
311-
assert_eq_mempool_queue(&mempool, &[same_input.tx])
311+
312+
// Assert: the original tx remains in Mempool after the failed attempt.
313+
let expected_mempool_state = MempoolState::with_pool([input.tx]);
314+
expected_mempool_state.assert_eq_pool_state(&mempool);
312315
}
313316

314317
#[rstest]

0 commit comments

Comments
 (0)