@@ -56,11 +56,11 @@ pub fn decode_v7(blob: &[u8]) -> Result<Batch, DecodingError> {
5656 } ;
5757
5858 // decode the payload.
59- decode_v7_payload ( buf)
59+ decode_v7_payload ( version , buf)
6060}
6161
6262/// Decode the blob data into a [`Batch`].
63- pub ( crate ) fn decode_v7_payload ( blob : & [ u8 ] ) -> Result < Batch , DecodingError > {
63+ pub ( crate ) fn decode_v7_payload ( version : u8 , blob : & [ u8 ] ) -> Result < Batch , DecodingError > {
6464 let buf = & mut ( & * blob) ;
6565
6666 // check buf len.
@@ -103,7 +103,7 @@ pub(crate) fn decode_v7_payload(blob: &[u8]) -> Result<Batch, DecodingError> {
103103 skipped_l1_message_bitmap : None ,
104104 } ;
105105
106- Ok ( Batch :: new ( 7 , None , payload) )
106+ Ok ( Batch :: new ( version , None , payload) )
107107}
108108
109109#[ cfg( test) ]
@@ -292,6 +292,26 @@ mod tests {
292292
293293 assert_eq ! ( last_block, & expected_block) ;
294294
295+
296+
297+ Ok ( ( ) )
298+ }
299+
300+ #[ test]
301+ fn test_should_decode_v8_mock ( ) -> eyre:: Result < ( ) > {
302+ let blob = read_to_bytes ( "./testdata/blob_v7_uncompressed.bin" ) ?;
303+ let mut blob = blob. to_vec ( ) ;
304+ // Manually patch the version byte to 8 to simulate a v8 blob.
305+ // BlobSliceIter skips the first byte (index 0) of every 32-byte chunk.
306+ // So the first data byte (version) is at index 1.
307+ blob[ 1 ] = 8 ;
308+
309+ let batch = decode_v7 ( & blob) ?;
310+ assert_eq ! ( batch. version, 8 ) ;
311+
312+ let blocks = batch. data . l2_blocks ( ) ;
313+ assert_eq ! ( blocks. len( ) , 4 ) ;
314+
295315 Ok ( ( ) )
296316 }
297317}
0 commit comments