op_alloy_protocol/batch/
element.rsuse crate::SingleBatch;
use alloc::vec::Vec;
use alloy_primitives::Bytes;
pub const MAX_SPAN_BATCH_ELEMENTS: u64 = 10_000_000;
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct SpanBatchElement {
pub epoch_num: u64,
pub timestamp: u64,
pub transactions: Vec<Bytes>,
}
impl From<SingleBatch> for SpanBatchElement {
fn from(batch: SingleBatch) -> Self {
Self {
epoch_num: batch.epoch_num,
timestamp: batch.timestamp,
transactions: batch.transactions,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use proptest::{collection::vec, prelude::any, proptest};
proptest! {
#[test]
fn test_span_batch_element_from_single_batch(epoch_num in 0u64..u64::MAX, timestamp in 0u64..u64::MAX, transactions in vec(any::<Bytes>(), 0..100)) {
let single_batch = SingleBatch {
epoch_num,
timestamp,
transactions: transactions.clone(),
..Default::default()
};
let span_batch_element: SpanBatchElement = single_batch.into();
assert_eq!(span_batch_element.epoch_num, epoch_num);
assert_eq!(span_batch_element.timestamp, timestamp);
assert_eq!(span_batch_element.transactions, transactions);
}
}
}