MCPcopy Create free account
hub / github.com/base/base / test_span_batch_encode_decode

Function test_span_batch_encode_decode

crates/consensus/protocol/src/batch/core.rs:101–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100 #[test]
101 fn test_span_batch_encode_decode() {
102 let sig = Signature::test_signature();
103 let to = address!("0123456789012345678901234567890123456789");
104 let tx = TxEnvelope::Eip2930(Signed::new_unchecked(
105 TxEip2930 { to: TxKind::Call(to), chain_id: 1, ..Default::default() },
106 sig,
107 Default::default(),
108 ));
109 let mut span_batch_txs = SpanBatchTransactions::default();
110 let mut buf = vec![];
111 tx.encode(&mut buf);
112 let txs = vec![Bytes::from(buf)];
113 let chain_id = 1;
114 span_batch_txs.add_txs(txs, chain_id).unwrap();
115
116 let mut out = Vec::new();
117 let batch = Batch::Span(SpanBatch {
118 block_tx_counts: vec![1],
119 batches: vec![SpanBatchElement::default()],
120 txs: span_batch_txs,
121 ..Default::default()
122 });
123 batch.encode(&mut out).unwrap();
124 let decoded = Batch::decode(&mut out.as_slice(), &RollupConfig::default()).unwrap();
125 assert_eq!(Batch::Span(SpanBatch {
126 batches: vec![SpanBatchElement {
127 transactions: vec![hex!("01f85f808080809401234567890123456789012345678901234567898080c080a0840cfc572845f5786e702984c2a582528cad4b49b2a10b9db1be7fca90058565a025e7109ceb98168d95b09b18bbf6b685130e0562f233877d492b94eee0c5b6d1").into()],
128 ..Default::default()
129 }],
130 txs: SpanBatchTransactions::default(),
131 ..Default::default()
132 }), decoded);
133 }
134
135 #[test]
136 fn test_empty_span_batch() {

Callers

nothing calls this directly

Calls 7

test_signatureFunction · 0.85
CallClass · 0.85
SpanClass · 0.85
add_txsMethod · 0.80
newFunction · 0.50
decodeFunction · 0.50
encodeMethod · 0.45

Tested by

no test coverage detected