@@ -41,6 +41,13 @@ func TestNewDigestFromByteStreamReadPath(t *testing.T) {
4141 })
4242
4343 t .Run ("NoInstanceName" , func (t * testing.T ) {
44+ t .Run ("BLAKE3" , func (t * testing.T ) {
45+ d , compressor , err := digest .NewDigestFromByteStreamReadPath ("blobs/blake3/af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262/123" )
46+ require .NoError (t , err )
47+ require .Equal (t , digest .MustNewDigest ("" , remoteexecution .DigestFunction_BLAKE3 , "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" , 123 ), d )
48+ require .Equal (t , remoteexecution .Compressor_IDENTITY , compressor )
49+ })
50+
4451 t .Run ("MD5" , func (t * testing.T ) {
4552 d , compressor , err := digest .NewDigestFromByteStreamReadPath ("blobs/8b1a9953c4611296a827abf8c47804d7/123" )
4653 require .NoError (t , err )
@@ -119,6 +126,13 @@ func TestNewDigestFromByteStreamWritePath(t *testing.T) {
119126 })
120127
121128 t .Run ("NoInstanceName" , func (t * testing.T ) {
129+ t .Run ("BLAKE3" , func (t * testing.T ) {
130+ d , compressor , err := digest .NewDigestFromByteStreamWritePath ("uploads/da2f1135-326b-4956-b920-1646cdd6cb53/blobs/blake3/af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262/123" )
131+ require .NoError (t , err )
132+ require .Equal (t , digest .MustNewDigest ("" , remoteexecution .DigestFunction_BLAKE3 , "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" , 123 ), d )
133+ require .Equal (t , remoteexecution .Compressor_IDENTITY , compressor )
134+ })
135+
122136 t .Run ("MD5" , func (t * testing.T ) {
123137 d , compressor , err := digest .NewDigestFromByteStreamWritePath ("uploads/da2f1135-326b-4956-b920-1646cdd6cb53/blobs/8b1a9953c4611296a827abf8c47804d7/123" )
124138 require .NoError (t , err )
@@ -182,6 +196,17 @@ func TestNewDigestFromByteStreamWritePath(t *testing.T) {
182196
183197func TestDigestGetByteStreamReadPath (t * testing.T ) {
184198 t .Run ("NoInstanceName" , func (t * testing.T ) {
199+ t .Run ("BLAKE3" , func (t * testing.T ) {
200+ require .Equal (
201+ t ,
202+ "blobs/blake3/af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262/123" ,
203+ digest .MustNewDigest (
204+ "" ,
205+ remoteexecution .DigestFunction_BLAKE3 ,
206+ "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" ,
207+ 123 ).GetByteStreamReadPath (remoteexecution .Compressor_IDENTITY ))
208+ })
209+
185210 t .Run ("MD5" , func (t * testing.T ) {
186211 require .Equal (
187212 t ,
@@ -242,6 +267,17 @@ func TestDigestGetByteStreamWritePath(t *testing.T) {
242267 uuid := uuid .Must (uuid .Parse ("36ebab65-3c4f-4faf-818b-2eabb4cd1b02" ))
243268
244269 t .Run ("NoInstanceName" , func (t * testing.T ) {
270+ t .Run ("BLAKE3" , func (t * testing.T ) {
271+ require .Equal (
272+ t ,
273+ "uploads/36ebab65-3c4f-4faf-818b-2eabb4cd1b02/blobs/blake3/af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262/123" ,
274+ digest .MustNewDigest (
275+ "" ,
276+ remoteexecution .DigestFunction_BLAKE3 ,
277+ "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" ,
278+ 123 ).GetByteStreamWritePath (uuid , remoteexecution .Compressor_IDENTITY ))
279+ })
280+
245281 t .Run ("MD5" , func (t * testing.T ) {
246282 require .Equal (
247283 t ,
@@ -409,6 +445,18 @@ func TestDigestGetSizeBytes(t *testing.T) {
409445}
410446
411447func TestDigestGetKey (t * testing.T ) {
448+ t .Run ("BLAKE3" , func (t * testing.T ) {
449+ d := digest .MustNewDigest ("hello" , remoteexecution .DigestFunction_BLAKE3 , "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" , 123 )
450+ require .Equal (
451+ t ,
452+ "9-af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262-123" ,
453+ d .GetKey (digest .KeyWithoutInstance ))
454+ require .Equal (
455+ t ,
456+ "9-af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262-123-hello" ,
457+ d .GetKey (digest .KeyWithInstance ))
458+ })
459+
412460 t .Run ("SHA256" , func (t * testing.T ) {
413461 d := digest .MustNewDigest ("hello" , remoteexecution .DigestFunction_SHA256 , "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" , 123 )
414462 require .Equal (
@@ -503,20 +551,40 @@ func TestRemoveUnsupportedDigestFunctions(t *testing.T) {
503551 require .Equal (
504552 t ,
505553 []remoteexecution.DigestFunction_Value {
554+ remoteexecution .DigestFunction_BLAKE3 ,
506555 remoteexecution .DigestFunction_MD5 ,
507556 remoteexecution .DigestFunction_SHA1 ,
508557 remoteexecution .DigestFunction_SHA256 ,
509558 },
510559 digest .RemoveUnsupportedDigestFunctions ([]remoteexecution.DigestFunction_Value {
560+ remoteexecution .DigestFunction_BLAKE3 ,
511561 remoteexecution .DigestFunction_MD5 ,
512- remoteexecution .DigestFunction_SHA256 ,
513562 remoteexecution .DigestFunction_SHA1 ,
514563 remoteexecution .DigestFunction_SHA1 ,
564+ remoteexecution .DigestFunction_SHA256 ,
515565 remoteexecution .DigestFunction_VSO ,
516566 }))
517567}
518568
519569func TestDigestGetCompactBinary (t * testing.T ) {
570+ t .Run ("BLAKE3" , func (t * testing.T ) {
571+ d := digest .MustNewDigest ("hello" , remoteexecution .DigestFunction_BLAKE3 , "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" , 124982395 )
572+ require .Equal (
573+ t ,
574+ []byte {
575+ // Digest function: remoteexecution.DigestFunction_BLAKE3.
576+ 0x09 ,
577+ // Hash.
578+ 0xaf , 0x13 , 0x49 , 0xb9 , 0xf5 , 0xf9 , 0xa1 , 0xa6 ,
579+ 0xa0 , 0x40 , 0x4d , 0xea , 0x36 , 0xdc , 0xc9 , 0x49 ,
580+ 0x9b , 0xcb , 0x25 , 0xc9 , 0xad , 0xc1 , 0x12 , 0xb7 ,
581+ 0xcc , 0x9a , 0x93 , 0xca , 0xe4 , 0x1f , 0x32 , 0x62 ,
582+ // Size.
583+ 0xf6 , 0xd1 , 0x98 , 0x77 ,
584+ },
585+ d .GetCompactBinary ())
586+ })
587+
520588 t .Run ("SHA256" , func (t * testing.T ) {
521589 d := digest .MustNewDigest ("hello" , remoteexecution .DigestFunction_SHA256 , "18c17f53df2fcd1f8271bc1c0e55df71b1a796eaa74ff45a68900f04e3f4c7a2" , 124982395 )
522590 require .Equal (
0 commit comments