Skip to content

Commit

Permalink
test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool …
Browse files Browse the repository at this point in the history
…state (#444)
  • Loading branch information
ayeletstarkware authored Jul 25, 2024
1 parent f1d94c0 commit a19df01
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl MempoolState<FullState> {
}

impl MempoolState<PartialState> {
fn _with_pool<P>(pool_txs: P) -> Self
fn with_pool<P>(pool_txs: P) -> Self
where
P: IntoIterator<Item = ThinTransaction>,
{
Expand Down Expand Up @@ -305,17 +305,20 @@ fn test_new_with_duplicate_tx() {

#[rstest]
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
// Setup.
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
let same_input = input.clone();
let duplicate_input = input.clone();

// Test.
add_tx(&mut mempool, &input);

assert_matches!(
mempool.add_tx(same_input.clone()),
mempool.add_tx(duplicate_input),
Err(MempoolError::DuplicateTransaction { .. })
);
// Assert that the original tx remains in the pool after the failed attempt.
assert_eq_mempool_queue(&mempool, &[same_input.tx])

// Assert: the original transaction remains.
let expected_mempool_state = MempoolState::with_pool([input.tx]);
expected_mempool_state.assert_eq_pool_state(&mempool);
}

#[rstest]
Expand Down

0 comments on commit a19df01

Please sign in to comment.