Skip to content

Commit

Permalink
feat: add --base-fee (foundry-rs#2059)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jun 22, 2022
1 parent 8d599c6 commit 83a2092
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion anvil/tests/it/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig};
use ethers::{
prelude::Middleware,
types::{Address, BlockNumber, TransactionRequest},
types::{transaction::eip2718::TypedTransaction, Address, BlockNumber, TransactionRequest},
};

const GAS_TRANSFER: u64 = 21_000u64;
Expand Down Expand Up @@ -67,3 +67,24 @@ async fn test_basefee_empty_block() {
// empty block, decreased base fee
assert!(next_base_fee < base_fee);
}

#[tokio::test(flavor = "multi_thread")]
async fn test_respect_base_fee() {
let base_fee = 50u64;
let (_api, handle) =
spawn(NodeConfig::test().with_port(next_port()).with_base_fee(Some(base_fee))).await;
let provider = handle.http_provider();
let mut tx = TypedTransaction::default();
tx.set_value(100u64);
tx.set_to(Address::random());

let mut underpriced = tx.clone();
underpriced.set_gas_price(base_fee - 1);
let res = provider.send_transaction(underpriced, None).await;
assert!(res.is_err());
assert!(res.unwrap_err().to_string().contains("max fee per gas less than block base fee"));

tx.set_gas_price(base_fee);
let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap();
assert_eq!(tx.status, Some(1u64.into()));
}

0 comments on commit 83a2092

Please sign in to comment.