From abd4470971b0f7315b2d42194656517caeaeb6dc Mon Sep 17 00:00:00 2001 From: int88 <106391185+int88@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:55:05 +0800 Subject: [PATCH] add remove logic in integration test of txpool listener (#15285) --- crates/transaction-pool/tests/it/listeners.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/transaction-pool/tests/it/listeners.rs b/crates/transaction-pool/tests/it/listeners.rs index 77cf5961b4..ad4361fa13 100644 --- a/crates/transaction-pool/tests/it/listeners.rs +++ b/crates/transaction-pool/tests/it/listeners.rs @@ -2,8 +2,8 @@ use assert_matches::assert_matches; use reth_transaction_pool::{ noop::MockTransactionValidator, test_utils::{MockTransactionFactory, TestPoolBuilder}, - FullTransactionEvent, TransactionEvent, TransactionListenerKind, TransactionOrigin, - TransactionPool, + FullTransactionEvent, PoolTransaction, TransactionEvent, TransactionListenerKind, + TransactionOrigin, TransactionPool, }; use std::{future::poll_fn, task::Poll}; use tokio_stream::StreamExt; @@ -21,6 +21,11 @@ async fn txpool_listener_by_hash() { let mut events = result.unwrap(); assert_matches!(events.next().await, Some(TransactionEvent::Pending)); + + let removed_txs = txpool.remove_transactions(vec![*transaction.transaction.hash()]); + assert_eq!(transaction.transaction.hash(), removed_txs[0].transaction.hash()); + + assert_matches!(events.next().await, Some(TransactionEvent::Discarded)); } #[tokio::test(flavor = "multi_thread")] @@ -39,6 +44,12 @@ async fn txpool_listener_all() { all_tx_events.next().await, Some(FullTransactionEvent::Pending(hash)) if hash == *transaction.transaction.get_hash() ); + + let removed_txs = txpool.remove_transactions(vec![*transaction.transaction.hash()]); + + assert_eq!(transaction.transaction.hash(), removed_txs[0].transaction.hash()); + + assert_matches!(all_tx_events.next().await, Some(FullTransactionEvent::Discarded(hash)) if hash == *transaction.transaction.get_hash()); } #[tokio::test(flavor = "multi_thread")]