From 47b6b3500ad83a377ff10a420ac373ec1b5e728b Mon Sep 17 00:00:00 2001 From: Mohammad Nassar Date: Sun, 7 Jul 2024 14:48:58 +0300 Subject: [PATCH] refactor(mempool): add error message in transaction queue --- crates/mempool/src/transaction_queue.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/mempool/src/transaction_queue.rs b/crates/mempool/src/transaction_queue.rs index 7e480286e..bbe80da78 100644 --- a/crates/mempool/src/transaction_queue.rs +++ b/crates/mempool/src/transaction_queue.rs @@ -20,8 +20,15 @@ pub struct TransactionQueue { impl TransactionQueue { /// Adds a transaction to the mempool, ensuring unique keys. /// Panics: if given a duplicate tx. + // TODO(Mohammad): Add test for two transactions from the same address, expecting specific + // assert. pub fn insert(&mut self, tx: TransactionReference) { - assert_eq!(self.address_to_nonce.insert(tx.sender_address, tx.nonce), None); + assert_eq!( + self.address_to_nonce.insert(tx.sender_address, tx.nonce), + None, + "Only a single transaction from the same contract class can be in the mempool at a \ + time." + ); assert!( self.queue.insert(tx.into()), "Keys should be unique; duplicates are checked prior."