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

Method encode

crates/batcher/encoder/tests/encoder/common.rs:85–101  ·  view source on GitHub ↗

Feed `encoder` the two blocks and take the two submissions, checking that the first tail is held back until the second channel fills the blob, and that the blob carries frames of both channels.

(encoder: &mut BatchEncoder)

Source from the content-addressed store, hash-verified

83 /// is held back until the second channel fills the blob, and that the blob carries frames of
84 /// both channels.
85 pub fn encode(encoder: &mut BatchEncoder) -> Self {
86 let blocks = BlockFixture::chain(2, MULTI_BLOB_PAYLOAD);
87 for block in &blocks {
88 encoder.add_block(block.clone()).unwrap();
89 }
90 assert_eq!(encoder.step().unwrap(), StepResult::ChannelClosed);
91 let first = encoder.next_submission().expect("the first channel fills a blob");
92 assert!(encoder.next_submission().is_none(), "its tail waits for more data");
93 assert_eq!(encoder.step().unwrap(), StepResult::ChannelClosed);
94 let packed = encoder.next_submission().expect("the tail and the next channel fill a blob");
95 let SubmissionPayload::Blobs(blobs) = packed.payload() else {
96 panic!("expected a blob submission");
97 };
98 let channels: HashSet<_> = blobs[0].frames().iter().map(|frame| frame.id).collect();
99 assert_eq!(channels.len(), 2, "the blob carries frames of both channels");
100 Self { blocks, first, packed }
101 }
102}
103
104/// An open channel that has handed out its first submission, fed blocks of

Callers 3

add_batchMethod · 0.45
to_calldataMethod · 0.45

Calls 9

chainFunction · 0.85
add_blockMethod · 0.45
cloneMethod · 0.45
next_submissionMethod · 0.45
payloadMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
framesMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected