Skip to content

Commit

Permalink
test(sidecar): duplicate transaction batch failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 3, 2024
1 parent 95ffbb3 commit c25b527
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions bolt-sidecar/src/state/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,46 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn test_invalid_inclusion_request_duplicate_batch() -> eyre::Result<()> {
let anvil = launch_anvil();
let client = StateClient::new(anvil.endpoint_url());

let limits = Limits {
max_commitments_per_slot: NonZero::new(10).unwrap(),
max_committed_gas_per_slot: NonZero::new(5_000_000).unwrap(),
min_priority_fee: NonZero::new(2 * GWEI_TO_WEI as u128).unwrap(),
};

let mut state = ExecutionState::new(client.clone(), limits).await?;

let sender = anvil.addresses().first().unwrap();
let sender_pk = anvil.keys().first().unwrap();

// initialize the state by updating the head once
let slot = client.get_head().await?;
state.update_head(None, slot).await?;

let base_fee = state.basefee();
let Some(max_base_fee) = calculate_max_basefee(base_fee, 10 - slot) else {
return Err(eyre::eyre!("Failed to calculate max base fee"));
};

// Create a transaction with a gas price that is too low
let tx = default_test_transaction(*sender, None)
.with_gas_price(max_base_fee + 3 * GWEI_TO_WEI as u128);

let mut request =
create_signed_commitment_request(&[tx.clone(), tx], sender_pk, 10).await?;

let response = state.validate_request(&mut request).await;
println!("{response:?}");

assert!(matches!(response, Err(ValidationError::NonceTooLow(_, _))));

Ok(())
}

#[tokio::test]
async fn test_invalidate_inclusion_request() -> eyre::Result<()> {
let _ = tracing_subscriber::fmt::try_init();
Expand Down

0 comments on commit c25b527

Please sign in to comment.