Skip to content

Commit

Permalink
chore(derive): Test Ignoring EIP-7702 (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell authored Jan 8, 2025
1 parent 3e88447 commit 02f5ba3
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion crates/derive/src/sources/calldata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ mod tests {
use super::*;
use crate::{errors::PipelineErrorKind, test_utils::TestChainProvider};
use alloc::{vec, vec::Vec};
use alloy_consensus::{Signed, TxEip2930, TxEip4844, TxEip4844Variant, TxLegacy};
use alloy_consensus::{Signed, TxEip2930, TxEip4844, TxEip4844Variant, TxEip7702, TxLegacy};
use alloy_primitives::{address, Address, PrimitiveSignature as Signature, TxKind};

pub(crate) fn test_legacy_tx(to: Address) -> TxEnvelope {
Expand All @@ -112,6 +112,15 @@ mod tests {
))
}

pub(crate) fn test_eip7702_tx(to: Address) -> TxEnvelope {
let sig = Signature::test_signature();
TxEnvelope::Eip7702(Signed::new_unchecked(
TxEip7702 { to, ..Default::default() },
sig,
Default::default(),
))
}

pub(crate) fn test_blob_tx(to: Address) -> TxEnvelope {
let sig = Signature::test_signature();
TxEnvelope::Eip4844(Signed::new_unchecked(
Expand Down Expand Up @@ -231,6 +240,21 @@ mod tests {
assert!(source.open);
}

#[tokio::test]
async fn test_load_calldata_eip7702_tx_ignored() {
let batch_inbox_address = address!("0123456789012345678901234567890123456789");
let mut source = default_test_calldata_source();
source.batch_inbox_address = batch_inbox_address;
let tx = test_eip7702_tx(batch_inbox_address);
source.signer = tx.recover_signer().unwrap();
let block_info = BlockInfo::default();
source.chain_provider.insert_block_with_transactions(0, block_info, vec![tx]);
assert!(!source.open); // Source is not open by default.
assert!(source.load_calldata(&BlockInfo::default()).await.is_ok());
assert!(source.calldata.is_empty());
assert!(source.open);
}

#[tokio::test]
async fn test_next_err_loading_calldata() {
let mut source = default_test_calldata_source();
Expand Down

0 comments on commit 02f5ba3

Please sign in to comment.