Skip to content

Commit

Permalink
fix(test): update insert_replace_underpriced_not_enough_bump
Browse files Browse the repository at this point in the history
  • Loading branch information
hai-rise committed Dec 6, 2024
1 parent d939876 commit f674342
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,28 +2448,28 @@ mod tests {
let first = f.validated(tx.clone());
let _ = pool.insert_tx(first.clone(), on_chain_balance, on_chain_nonce).unwrap();
let mut replacement = f.validated(tx.rng_hash().inc_price());

// a price bump of 9% is not enough for a default min price bump of 10%
replacement.transaction.set_priority_fee(109);
replacement.transaction.set_max_fee(109);
let err =
pool.insert_tx(replacement.clone(), on_chain_balance, on_chain_nonce).unwrap_err();
assert!(matches!(err, InsertErr::Underpriced { .. }));

// ensure first tx is not removed
assert!(pool.contains(first.hash()));
assert_eq!(pool.len(), 1);

// price bump of 10% is also not enough because the bump should be strictly greater than 10%
// should also fail if the bump in max fee is not enough
replacement.transaction.set_priority_fee(110);
replacement.transaction.set_max_fee(110);
replacement.transaction.set_max_fee(109);
let err =
pool.insert_tx(replacement.clone(), on_chain_balance, on_chain_nonce).unwrap_err();
assert!(matches!(err, InsertErr::Underpriced { .. }));
assert!(pool.contains(first.hash()));
assert_eq!(pool.len(), 1);

// should also fail if the bump in priority fee is not enough
replacement.transaction.set_priority_fee(111);
replacement.transaction.set_priority_fee(109);
replacement.transaction.set_max_fee(110);
let err = pool.insert_tx(replacement, on_chain_balance, on_chain_nonce).unwrap_err();
assert!(matches!(err, InsertErr::Underpriced { .. }));
Expand Down

0 comments on commit f674342

Please sign in to comment.