kona_protocol/batch/
element.rs1use crate::SingleBatch;
4use alloc::vec::Vec;
5use alloy_primitives::Bytes;
6
7pub const MAX_SPAN_BATCH_ELEMENTS: u64 = 10_000_000;
10
11#[derive(Debug, Default, Clone, PartialEq, Eq)]
15pub struct SpanBatchElement {
16 pub epoch_num: u64,
18 pub timestamp: u64,
20 pub transactions: Vec<Bytes>,
22}
23
24impl From<SingleBatch> for SpanBatchElement {
25 fn from(batch: SingleBatch) -> Self {
26 Self {
27 epoch_num: batch.epoch_num,
28 timestamp: batch.timestamp,
29 transactions: batch.transactions,
30 }
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37 use proptest::{collection::vec, prelude::any, proptest};
38
39 proptest! {
40 #[test]
41 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)) {
42 let single_batch = SingleBatch {
43 epoch_num,
44 timestamp,
45 transactions: transactions.clone(),
46 ..Default::default()
47 };
48
49 let span_batch_element: SpanBatchElement = single_batch.into();
50
51 assert_eq!(span_batch_element.epoch_num, epoch_num);
52 assert_eq!(span_batch_element.timestamp, timestamp);
53 assert_eq!(span_batch_element.transactions, transactions);
54 }
55 }
56}