@@ -423,11 +423,11 @@ func verifyBlobRetrievals(t *testing.T, pool *BlobPool) {
423
423
hashes = append (hashes , tx .vhashes ... )
424
424
}
425
425
}
426
- blobs1 , _ , proofs1 , err := pool .GetBlobs (hashes , types .BlobSidecarVersion0 )
426
+ blobs1 , _ , proofs1 , err := pool .GetBlobs (hashes , types .BlobSidecarVersion0 , false )
427
427
if err != nil {
428
428
t .Fatal (err )
429
429
}
430
- blobs2 , _ , proofs2 , err := pool .GetBlobs (hashes , types .BlobSidecarVersion1 )
430
+ blobs2 , _ , proofs2 , err := pool .GetBlobs (hashes , types .BlobSidecarVersion1 , false )
431
431
if err != nil {
432
432
t .Fatal (err )
433
433
}
@@ -441,22 +441,18 @@ func verifyBlobRetrievals(t *testing.T, pool *BlobPool) {
441
441
return
442
442
}
443
443
for i , hash := range hashes {
444
- // If an item is missing, but shouldn't, error
445
- if blobs1 [i ] == nil || proofs1 [i ] == nil {
446
- t .Errorf ("tracked blob retrieval failed: item %d, hash %x" , i , hash )
447
- continue
448
- }
449
- if blobs2 [i ] == nil || proofs2 [i ] == nil {
444
+ // If an item is missing from both, but shouldn't, error
445
+ if (blobs1 [i ] == nil || proofs1 [i ] == nil ) && (blobs2 [i ] == nil || proofs2 [i ] == nil ) {
450
446
t .Errorf ("tracked blob retrieval failed: item %d, hash %x" , i , hash )
451
447
continue
452
448
}
453
449
// Item retrieved, make sure it matches the expectation
454
450
index := testBlobIndices [hash ]
455
- if * blobs1 [i ] != * testBlobs [index ] || proofs1 [i ][0 ] != testBlobProofs [index ] {
451
+ if blobs1 [ i ] != nil && ( * blobs1 [i ] != * testBlobs [index ] || proofs1 [i ][0 ] != testBlobProofs [index ]) {
456
452
t .Errorf ("retrieved blob or proof mismatch: item %d, hash %x" , i , hash )
457
453
continue
458
454
}
459
- if * blobs2 [i ] != * testBlobs [index ] || ! slices .Equal (proofs2 [i ], testBlobCellProofs [index ]) {
455
+ if blobs2 [ i ] != nil && ( * blobs2 [i ] != * testBlobs [index ] || ! slices .Equal (proofs2 [i ], testBlobCellProofs [index ]) ) {
460
456
t .Errorf ("retrieved blob or proof mismatch: item %d, hash %x" , i , hash )
461
457
continue
462
458
}
@@ -1926,8 +1922,9 @@ func TestGetBlobs(t *testing.T) {
1926
1922
cases := []struct {
1927
1923
start int
1928
1924
limit int
1929
- fillRandom bool
1930
- version byte
1925
+ fillRandom bool // Whether to randomly fill some of the requested blobs with unknowns
1926
+ version byte // Blob sidecar version to request
1927
+ convert bool // Whether to convert version on retrieval
1931
1928
}{
1932
1929
{
1933
1930
start : 0 , limit : 6 ,
@@ -1993,6 +1990,11 @@ func TestGetBlobs(t *testing.T) {
1993
1990
start : 0 , limit : 18 , fillRandom : true ,
1994
1991
version : types .BlobSidecarVersion1 ,
1995
1992
},
1993
+ {
1994
+ start : 0 , limit : 18 , fillRandom : true ,
1995
+ version : types .BlobSidecarVersion1 ,
1996
+ convert : true , // Convert some version 0 blobs to version 1 while retrieving
1997
+ },
1996
1998
}
1997
1999
for i , c := range cases {
1998
2000
var (
@@ -2014,7 +2016,7 @@ func TestGetBlobs(t *testing.T) {
2014
2016
filled [len (vhashes )] = struct {}{}
2015
2017
vhashes = append (vhashes , testrand .Hash ())
2016
2018
}
2017
- blobs , _ , proofs , err := pool .GetBlobs (vhashes , c .version )
2019
+ blobs , _ , proofs , err := pool .GetBlobs (vhashes , c .version , c . convert )
2018
2020
if err != nil {
2019
2021
t .Errorf ("Unexpected error for case %d, %v" , i , err )
2020
2022
}
@@ -2029,6 +2031,7 @@ func TestGetBlobs(t *testing.T) {
2029
2031
2030
2032
var unknown int
2031
2033
for j := 0 ; j < len (blobs ); j ++ {
2034
+ testBlobIndex := c .start + j - unknown
2032
2035
if _ , exist := filled [j ]; exist {
2033
2036
if blobs [j ] != nil || proofs [j ] != nil {
2034
2037
t .Errorf ("Unexpected blob and proof, item %d" , j )
@@ -2038,17 +2041,22 @@ func TestGetBlobs(t *testing.T) {
2038
2041
}
2039
2042
// If an item is missing, but shouldn't, error
2040
2043
if blobs [j ] == nil || proofs [j ] == nil {
2041
- t .Errorf ("tracked blob retrieval failed: item %d, hash %x" , j , vhashes [j ])
2044
+ // This is only an error if there was no version mismatch
2045
+ if c .convert ||
2046
+ (c .version == types .BlobSidecarVersion1 && 6 <= testBlobIndex && testBlobIndex < 12 ) ||
2047
+ (c .version == types .BlobSidecarVersion0 && (testBlobIndex < 6 || 12 <= testBlobIndex )) {
2048
+ t .Errorf ("tracked blob retrieval failed: item %d, hash %x" , j , vhashes [j ])
2049
+ }
2042
2050
continue
2043
2051
}
2044
2052
// Item retrieved, make sure the blob matches the expectation
2045
- if * blobs [j ] != * testBlobs [c . start + j - unknown ] {
2053
+ if * blobs [j ] != * testBlobs [testBlobIndex ] {
2046
2054
t .Errorf ("retrieved blob mismatch: item %d, hash %x" , j , vhashes [j ])
2047
2055
continue
2048
2056
}
2049
2057
// Item retrieved, make sure the proof matches the expectation
2050
2058
if c .version == types .BlobSidecarVersion0 {
2051
- if proofs [j ][0 ] != testBlobProofs [c . start + j - unknown ] {
2059
+ if proofs [j ][0 ] != testBlobProofs [testBlobIndex ] {
2052
2060
t .Errorf ("retrieved proof mismatch: item %d, hash %x" , j , vhashes [j ])
2053
2061
}
2054
2062
} else {
0 commit comments