Skip to content

Commit f33ec6d

Browse files
test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool state
1 parent 9852d18 commit f33ec6d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

crates/mempool/src/mempool_test.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,23 @@ fn test_new_with_duplicate_tx() {
223223

224224
#[rstest]
225225
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
226+
// Setup
226227
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
227-
let same_input = input.clone();
228+
let duplicate_input = input.clone();
228229

230+
// Test: assert that the duplicate tx is not added to the mempool.
229231
add_tx(&mut mempool, &input);
230-
231232
assert_matches!(
232-
mempool.add_tx(same_input.clone()),
233+
mempool.add_tx(duplicate_input),
233234
Err(MempoolError::DuplicateTransaction { .. })
234235
);
235-
// Assert that the original tx remains in the pool after the failed attempt.
236-
assert_eq_mempool_queue(&mempool, &[same_input.tx])
236+
237+
// Assert that the original tx remains in Mempool after the failed attempt.
238+
let expected_queue_txs = [TransactionReference::new(&input.tx)];
239+
let expected_pool_txs = [input.tx];
240+
let expected_mempool_state = MempoolState::new(expected_pool_txs, expected_queue_txs);
241+
242+
expected_mempool_state.assert_eq_mempool_state(&mempool);
237243
}
238244

239245
#[rstest]

0 commit comments

Comments
 (0)