diff --git a/src/broadcast_utils.rs b/src/broadcast_utils.rs index 0b97892..35c9318 100644 --- a/src/broadcast_utils.rs +++ b/src/broadcast_utils.rs @@ -12,19 +12,10 @@ pub fn calculate_gas_fees_from_estimates( tx_priority_index: usize, max_base_fee_per_gas: U256, ) -> (U256, U256) { - println!("estimates = {estimates:#?}"); - let max_priority_fee_per_gas = estimates.percentile_fees[tx_priority_index]; let max_fee_per_gas = max_base_fee_per_gas + max_priority_fee_per_gas; - println!( - "max_base_fee_per_gas = {max_base_fee_per_gas}, max_priority_fee_per_gas = {max_priority_fee_per_gas}, max_fee_per_gas = {max_fee_per_gas}", - max_base_fee_per_gas = max_base_fee_per_gas, - max_priority_fee_per_gas = max_priority_fee_per_gas, - max_fee_per_gas = max_fee_per_gas, - ); - (max_fee_per_gas, max_priority_fee_per_gas) } diff --git a/src/tasks/broadcast.rs b/src/tasks/broadcast.rs index 8e46612..7f33f21 100644 --- a/src/tasks/broadcast.rs +++ b/src/tasks/broadcast.rs @@ -5,7 +5,7 @@ use std::time::Duration; use ethers::providers::Middleware; use ethers::types::transaction::eip2718::TypedTransaction; use ethers::types::transaction::eip2930::AccessList; -use ethers::types::{Address, Eip1559TransactionRequest, NameOrAddress, H256, U256}; +use ethers::types::{Address, Eip1559TransactionRequest, NameOrAddress, H256}; use eyre::ContextCompat; use futures::stream::FuturesUnordered; use futures::StreamExt; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 10490dd..84c0d10 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -10,8 +10,6 @@ use ethers::providers::{Http, Middleware, Provider}; use ethers::signers::{LocalWallet, Signer}; use ethers::types::{Address, Eip1559TransactionRequest, H160, U256}; use ethers::utils::{Anvil, AnvilInstance}; -use futures::stream::FuturesUnordered; -use futures::StreamExt; use postgres_docker_utils::DockerContainerGuard; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; @@ -73,7 +71,7 @@ pub fn setup_tracing() { EnvFilter::builder() .with_default_directive(LevelFilter::INFO.into()) // Logging from fake_rpc can get very messy so we set it to warn only - .parse_lossy("info,fake_rpc=warn"), + .parse_lossy("info,tx_sitter=debug,fake_rpc=warn"), ) .init(); } @@ -92,32 +90,21 @@ pub async fn setup_anvil(block_time: u64) -> eyre::Result { let middleware = setup_middleware(anvil.endpoint(), SECONDARY_ANVIL_PRIVATE_KEY).await?; + // Wait for the chain to start and produce at least one block + tokio::time::sleep(Duration::from_secs(block_time)).await; + // We need to seed some transactions so we can get fee estimates on the first block - // let mut nonce = 0; - // let mut futures = FuturesUnordered::new(); - // for i in 0..100 { - // let tx = middleware - // .send_transaction( - // Eip1559TransactionRequest { - // nonce: Some(U256::from(nonce)), - // to: Some(DEFAULT_ANVIL_ACCOUNT.into()), - // value: Some(U256::from(100u64)), - // max_fee_per_gas: Some(U256::from(40_000_000_000u64)), - // max_priority_fee_per_gas: Some(U256::from(10_000u64)), - // ..Default::default() - // }, - // None, - // ) - // .await?; - - // futures.push(tx); - - // nonce += 1; - // } - - // while let Some(tx) = futures.next().await { - // tx?; - // } + middleware + .send_transaction( + Eip1559TransactionRequest { + to: Some(DEFAULT_ANVIL_ACCOUNT.into()), + value: Some(U256::from(100u64)), + ..Default::default() + }, + None, + ) + .await? + .await?; Ok(anvil) } diff --git a/tests/escalation.rs b/tests/escalation.rs index 97e34b0..ae7ad0d 100644 --- a/tests/escalation.rs +++ b/tests/escalation.rs @@ -36,13 +36,13 @@ async fn escalation() -> eyre::Result<()> { ) .await?; - for _ in 0..10 { + for _ in 0..24 { let balance = provider.get_balance(ARBITRARY_ADDRESS, None).await?; if balance == value { return Ok(()); } else { - tokio::time::sleep(Duration::from_secs(5)).await; + tokio::time::sleep(Duration::from_secs(3)).await; } }