mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
respect gas limit for test_best_transactions_prioritized_senders() (#15076)
This commit is contained in:
@@ -772,17 +772,24 @@ mod tests {
|
||||
|
||||
// Add 5 plain transactions from different senders with increasing gas price
|
||||
for gas_price in 0..5 {
|
||||
let tx = MockTransaction::eip1559().with_gas_price(gas_price);
|
||||
let tx = MockTransaction::eip1559().with_gas_price((gas_price + 1) * 10);
|
||||
let valid_tx = f.validated(tx);
|
||||
pool.add_transaction(Arc::new(valid_tx), 0);
|
||||
}
|
||||
|
||||
// Add another transaction with 0 gas price that's going to be prioritized by sender
|
||||
let prioritized_tx = MockTransaction::eip1559().with_gas_price(0);
|
||||
// Add another transaction with 5 gas price that's going to be prioritized by sender
|
||||
let prioritized_tx = MockTransaction::eip1559().with_gas_price(5).with_gas_limit(200);
|
||||
let valid_prioritized_tx = f.validated(prioritized_tx.clone());
|
||||
pool.add_transaction(Arc::new(valid_prioritized_tx), 0);
|
||||
|
||||
let prioritized_senders = HashSet::from([prioritized_tx.sender()]);
|
||||
// Add another transaction with 3 gas price that should not be prioritized by sender because
|
||||
// of gas limit.
|
||||
let prioritized_tx2 = MockTransaction::eip1559().with_gas_price(3);
|
||||
let valid_prioritized_tx2 = f.validated(prioritized_tx2.clone());
|
||||
pool.add_transaction(Arc::new(valid_prioritized_tx2), 0);
|
||||
|
||||
let prioritized_senders =
|
||||
HashSet::from([prioritized_tx.sender(), prioritized_tx2.sender()]);
|
||||
let best =
|
||||
BestTransactionsWithPrioritizedSenders::new(prioritized_senders, 200, pool.best());
|
||||
|
||||
@@ -790,13 +797,17 @@ mod tests {
|
||||
// and the rest are returned in the reverse order of gas price
|
||||
let mut iter = best.into_iter();
|
||||
let top_of_block_tx = iter.next().unwrap();
|
||||
assert_eq!(top_of_block_tx.max_fee_per_gas(), 0);
|
||||
assert_eq!(top_of_block_tx.max_fee_per_gas(), 5);
|
||||
assert_eq!(top_of_block_tx.sender(), prioritized_tx.sender());
|
||||
for gas_price in (0..5).rev() {
|
||||
assert_eq!(iter.next().unwrap().max_fee_per_gas(), gas_price);
|
||||
assert_eq!(iter.next().unwrap().max_fee_per_gas(), (gas_price + 1) * 10);
|
||||
}
|
||||
|
||||
// TODO: Test that gas limits for prioritized transactions are respected
|
||||
// Due to the gas limit, the transaction from second prioritized sender was not
|
||||
// prioritized.
|
||||
let top_of_block_tx2 = iter.next().unwrap();
|
||||
assert_eq!(top_of_block_tx2.max_fee_per_gas(), 3);
|
||||
assert_eq!(top_of_block_tx2.sender(), prioritized_tx2.sender());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user