@@ -53,7 +53,7 @@ mod test {
5353 use super :: * ;
5454 use crate :: { Blobs , utils:: tests:: PYLON_BLOB_RESPONSE } ;
5555 use alloy:: {
56- consensus:: { BlobTransactionSidecar , SimpleCoder } ,
56+ consensus:: { Blob , BlobTransactionSidecar , Bytes48 , SimpleCoder } ,
5757 primitives:: { Address , B256 , U256 , b256} ,
5858 } ;
5959 use signet_zenith:: Zenith ;
@@ -101,4 +101,36 @@ mod test {
101101
102102 assert_eq ! ( block. transactions( ) . len( ) , 0 ) ;
103103 }
104+
105+ #[ test]
106+ fn it_fails_to_decode_junk ( ) {
107+ let mut blob = Blob :: default ( ) ;
108+
109+ blob. as_mut_slice ( ) [ 0 ..32 ] . copy_from_slice ( & [
110+ 0x10 , 0xa , 0xb , 0xc , 0xd , 0xe , 0xf , 0x0 , 0x10 , 0xa , 0xb , 0xc , 0xd , 0xe , 0xf , 0x0 , 0x10 ,
111+ 0xa , 0xb , 0xc , 0xd , 0xe , 0xf , 0x0 , 0x10 , 0xa , 0xb , 0xc , 0xd , 0xe , 0xf , 0x0 ,
112+ ] ) ;
113+
114+ let sidecar = BlobTransactionSidecar :: new (
115+ vec ! [ blob] ,
116+ vec ! [ Bytes48 :: default ( ) ] ,
117+ vec ! [ Bytes48 :: default ( ) ] ,
118+ ) ;
119+ let blobs = Blobs :: from ( sidecar) ;
120+
121+ let err = SimpleCoder :: default ( )
122+ . decode_block (
123+ blobs,
124+ Zenith :: BlockHeader {
125+ rollupChainId : U256 :: ZERO ,
126+ hostBlockNumber : U256 :: ZERO ,
127+ gasLimit : U256 :: ZERO ,
128+ rewardAddress : Address :: ZERO ,
129+ blockDataHash : B256 :: ZERO ,
130+ } ,
131+ B256 :: ZERO ,
132+ )
133+ . unwrap_err ( ) ;
134+ assert ! ( matches!( err, DecodeError :: BlobDecodeError ) ) ;
135+ }
104136}
0 commit comments