@@ -2016,7 +2016,7 @@ func TestGetBlobsV1AfterOsakaFork(t *testing.T) {
20162016 }
20172017}
20182018
2019- func TestGetBlobsV2 (t * testing.T ) {
2019+ func TestGetBlobsV2And3 (t * testing.T ) {
20202020 n , api := newGetBlobEnv (t , 1 )
20212021 defer n .Close ()
20222022
@@ -2045,7 +2045,8 @@ func TestGetBlobsV2(t *testing.T) {
20452045 },
20462046 }
20472047 for i , suite := range suites {
2048- runGetBlobsV2 (t , api , suite .start , suite .limit , suite .fillRandom , fmt .Sprintf ("suite=%d" , i ))
2048+ runGetBlobs (t , api .GetBlobsV2 , suite .start , suite .limit , suite .fillRandom , false , fmt .Sprintf ("GetBlobsV2 suite=%d" , i ))
2049+ runGetBlobs (t , api .GetBlobsV3 , suite .start , suite .limit , suite .fillRandom , true , fmt .Sprintf ("GetBlobsV3 suite=%d %v" , i , suite ))
20492050 }
20502051}
20512052
@@ -2060,22 +2061,20 @@ func BenchmarkGetBlobsV2(b *testing.B) {
20602061 name := fmt .Sprintf ("blobs=%d" , blobs )
20612062 b .Run (name , func (b * testing.B ) {
20622063 for b .Loop () {
2063- runGetBlobsV2 (b , api , 0 , blobs , false , name )
2064+ runGetBlobs (b , api . GetBlobsV2 , 0 , blobs , false , false , name )
20642065 }
20652066 })
20662067 }
20672068}
20682069
2069- func runGetBlobsV2 (t testing.TB , api * ConsensusAPI , start , limit int , fillRandom bool , name string ) {
2070+ type getBlobsFn func (hashes []common.Hash ) ([]* engine.BlobAndProofV2 , error )
2071+
2072+ func runGetBlobs (t testing.TB , getBlobs getBlobsFn , start , limit int , fillRandom bool , expectPartialResponse bool , name string ) {
20702073 // Fill the request for retrieving blobs
20712074 var (
20722075 vhashes []common.Hash
20732076 expect []* engine.BlobAndProofV2
20742077 )
2075- // fill missing blob
2076- if fillRandom {
2077- vhashes = append (vhashes , testrand .Hash ())
2078- }
20792078 for j := start ; j < limit ; j ++ {
20802079 vhashes = append (vhashes , testBlobVHashes [j ])
20812080 var cellProofs []hexutil.Bytes
@@ -2087,13 +2086,21 @@ func runGetBlobsV2(t testing.TB, api *ConsensusAPI, start, limit int, fillRandom
20872086 CellProofs : cellProofs ,
20882087 })
20892088 }
2090- result , err := api .GetBlobsV2 (vhashes )
2089+ // fill missing blob
2090+ if fillRandom {
2091+ vhashes = append (vhashes , testrand .Hash ())
2092+ }
2093+ result , err := getBlobs (vhashes )
20912094 if err != nil {
20922095 t .Errorf ("Unexpected error for case %s, %v" , name , err )
20932096 }
2094- // null is responded if any blob is missing
20952097 if fillRandom {
2096- expect = nil
2098+ if expectPartialResponse {
2099+ expect = append (expect , nil )
2100+ } else {
2101+ // Nil is expected if getBlobs can not return a partial response
2102+ expect = nil
2103+ }
20972104 }
20982105 if ! reflect .DeepEqual (result , expect ) {
20992106 t .Fatalf ("Unexpected result for case %s" , name )
0 commit comments