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
  • Loading branch information
ayeletstarkware committed Jul 15, 2024
1 parent 9852d18 commit 2845247
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,22 @@ fn test_new_with_duplicate_tx() {
#[rstest]
fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) {
let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE);
let same_input = input.clone();
let duplicate_input = input.clone();

add_tx(&mut mempool, &input);

// Assert that the duplicate tx is not added to the mempool.
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 that the original tx remains in Mempool after the failed attempt.
let expected_queue_txs = [TransactionReference::new(&input.tx)];
let expected_pool_txs = [input.tx];
let expected_mempool_state = MempoolState::new(expected_pool_txs, expected_queue_txs);

expected_mempool_state.assert_eq_mempool_state(&mempool);
}

#[rstest]
Expand Down

0 comments on commit 2845247

Please sign in to comment.