Skip to content

Commit

Permalink
test: add test case for BestTransactions (paradigmxyz#12209)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 30, 2024
1 parent 0c39704 commit 09c666d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/transaction-pool/src/pool/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,29 @@ mod tests {
assert!(best.next().is_none());
}

#[test]
fn test_best_transactions_iter_invalid() {
let mut pool = PendingPool::new(MockOrdering::default());
let mut f = MockTransactionFactory::default();

let num_tx = 10;
// insert 10 gapless tx
let tx = MockTransaction::eip1559();
for nonce in 0..num_tx {
let tx = tx.clone().rng_hash().with_nonce(nonce);
let valid_tx = f.validated(tx);
pool.add_transaction(Arc::new(valid_tx), 0);
}

let mut best: Box<
dyn crate::traits::BestTransactions<Item = Arc<ValidPoolTransaction<MockTransaction>>>,
> = Box::new(pool.best());

let tx = best.next().unwrap();
best.mark_invalid(&tx);
assert!(best.next().is_none());
}

#[test]
fn test_best_with_fees_iter_base_fee_satisfied() {
let mut pool = PendingPool::new(MockOrdering::default());
Expand Down

0 comments on commit 09c666d

Please sign in to comment.