Minimal effective gas price in the queue (#8934)
* Minimal effective gas price. * Fix naming, add test * Fix minimal entry score and add test. * Fix worst_transaction. * Remove effective gas price threshold. * Don't leak gas_price decisions out of Scoring.
This commit is contained in:
committed by
Afri Schoedon
parent
47ff3a9bee
commit
1792725651
@@ -875,8 +875,8 @@ fn should_avoid_verifying_transaction_already_in_pool() {
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
let client = TestClient::new();
|
||||
let tx1 = Tx::default().signed().unverified();
|
||||
let client = TestClient::new().with_balance(1_000_000_000);
|
||||
let tx1 = Tx::gas_price(2).signed().unverified();
|
||||
|
||||
let res = txq.import(client.clone(), vec![tx1.clone()]);
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
@@ -892,3 +892,41 @@ fn should_avoid_verifying_transaction_already_in_pool() {
|
||||
// then
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
||||
// given
|
||||
let txq = TransactionQueue::new(
|
||||
txpool::Options {
|
||||
max_count: 1,
|
||||
max_per_sender: 2,
|
||||
max_mem_usage: 50
|
||||
},
|
||||
verifier::Options {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
let client = TestClient::new().with_balance(1_000_000_000);
|
||||
let tx1 = Tx::gas_price(2).signed().unverified();
|
||||
|
||||
let res = txq.import(client.clone(), vec![tx1]);
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
assert!(client.was_verification_triggered());
|
||||
|
||||
// when
|
||||
let client = TestClient::new();
|
||||
let tx1 = Tx::default().signed().unverified();
|
||||
let res = txq.import(client.clone(), vec![tx1]);
|
||||
assert_eq!(res, vec![Err(transaction::Error::InsufficientGasPrice {
|
||||
minimal: 2.into(),
|
||||
got: 1.into(),
|
||||
})]);
|
||||
assert!(!client.was_verification_triggered());
|
||||
|
||||
// then
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user