From 284524709e819c2518738b2508623111d1efda32 Mon Sep 17 00:00:00 2001 From: Ayelet Zilber Date: Thu, 11 Jul 2024 12:13:16 +0300 Subject: [PATCH] test(mempool): refactor test_add_tx_with_duplicate_tx to use mempool state --- crates/mempool/src/mempool_test.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index ce37b73a7..bf61f3e3a 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -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]