@@ -42,9 +42,9 @@ func TestFiberClient_Submit_Success(t *testing.T) {
4242 res := cl .Submit (context .Background (), [][]byte {[]byte ("hello" ), []byte ("world" )}, 0 , ns , nil )
4343
4444 require .Equal (t , datypes .StatusSuccess , res .Code )
45- require .Len (t , res .IDs , 2 )
45+ require .Len (t , res .IDs , 1 )
4646 require .Equal (t , uint64 (2 ), res .SubmittedCount )
47- require .Greater (t , res . Height , uint64 (0 ))
47+ require .Equal (t , uint64 (0 ), res . Height )
4848 require .Equal (t , uint64 (10 ), res .BlobSize )
4949}
5050
@@ -133,6 +133,8 @@ func TestFiberClient_Submit_BlobTooLarge(t *testing.T) {
133133}
134134
135135func TestFiberClient_Retrieve_Success (t * testing.T ) {
136+ t .Skip ("pending Height tracking from fiber DA" )
137+
136138 _ , cl := makeTestFiberClient (t )
137139
138140 ns := datypes .NamespaceFromString ("test-ns" ).Bytes ()
@@ -147,7 +149,7 @@ func TestFiberClient_Retrieve_Success(t *testing.T) {
147149}
148150
149151func TestFiberClient_RetrieveBlobs_Success (t * testing.T ) {
150- t .Skip () // not implemented
152+ t .Skip ("pending Height tracking from fiber DA" )
151153
152154 _ , cl := makeTestFiberClient (t )
153155
@@ -171,6 +173,8 @@ func TestFiberClient_Retrieve_NotFound(t *testing.T) {
171173}
172174
173175func TestFiberClient_Retrieve_NamespaceFiltering (t * testing.T ) {
176+ t .Skip ("pending Height tracking from fiber DA" )
177+
174178 _ , cl := makeTestFiberClient (t )
175179
176180 ns1 := datypes .NamespaceFromString ("ns-a" ).Bytes ()
@@ -347,12 +351,13 @@ func TestFiberClient_NoForcedNamespace(t *testing.T) {
347351}
348352
349353func TestFiberClient_Subscribe (t * testing.T ) {
354+ t .Skip ("pending Height tracking from fiber DA" )
350355 _ , cl := makeTestFiberClient (t )
351356
352357 ctx , cancel := context .WithCancel (context .Background ())
353358 defer cancel ()
354359
355- ch , err := cl .Subscribe (ctx , nil , false )
360+ ch , err := cl .Subscribe (ctx , datypes . NamespaceFromString ( "test-ns" ). Bytes () , false )
356361 require .NoError (t , err )
357362 require .NotNil (t , ch )
358363
@@ -371,24 +376,22 @@ func TestFiberClient_Subscribe(t *testing.T) {
371376}
372377
373378func TestFiberClient_Submit_MultipleBlobs (t * testing.T ) {
374- t .Skip () // not implemented
375-
376379 _ , cl := makeTestFiberClient (t )
377380
378381 ns := datypes .NamespaceFromString ("test-ns" ).Bytes ()
379382 data := [][]byte {[]byte ("first" ), []byte ("second" ), []byte ("third" )}
380383 res := cl .Submit (context .Background (), data , 0 , ns , nil )
381384
382385 require .Equal (t , datypes .StatusSuccess , res .Code )
383- require .Len (t , res .IDs , 3 )
386+ require .Len (t , res .IDs , 1 )
384387 require .Equal (t , uint64 (3 ), res .SubmittedCount )
385388
386- retrieveRes := cl .Retrieve (context .Background (), res .Height , ns )
387- require .Equal (t , datypes . StatusSuccess , retrieveRes . Code )
388- require .Len (t , retrieveRes . Data , 3 )
389- require .Equal (t , []byte ("first" ), retrieveRes . Data [0 ])
390- require .Equal (t , []byte ("second" ), retrieveRes . Data [1 ])
391- require .Equal (t , []byte ("third" ), retrieveRes . Data [2 ])
389+ blobs , err := cl .Get (context .Background (), res .IDs , ns )
390+ require .NoError (t , err )
391+ require .Len (t , blobs , 3 )
392+ require .Equal (t , []byte ("first" ), blobs [0 ])
393+ require .Equal (t , []byte ("second" ), blobs [1 ])
394+ require .Equal (t , []byte ("third" ), blobs [2 ])
392395}
393396
394397func TestFiberClient_SubmitAndDownload (t * testing.T ) {
@@ -477,3 +480,61 @@ func (f *failOnNthUpload) Upload(ctx context.Context, namespace, data []byte) (f
477480 }
478481 return f .FiberClient .Upload (ctx , namespace , data )
479482}
483+
484+ func TestFlattenSplitBlobs_Roundtrip (t * testing.T ) {
485+ cases := []struct {
486+ name string
487+ blobs [][]byte
488+ }{
489+ {"single" , [][]byte {[]byte ("hello" )}},
490+ {"multiple" , [][]byte {[]byte ("first" ), []byte ("second" ), []byte ("third" )}},
491+ {"empty_blob" , [][]byte {[]byte {}, []byte ("data" ), []byte {}}},
492+ {"nil_blob" , [][]byte {nil , []byte ("data" )}},
493+ {"large" , [][]byte {make ([]byte , 1024 ), make ([]byte , 4096 )}},
494+ }
495+
496+ for _ , tc := range cases {
497+ t .Run (tc .name , func (t * testing.T ) {
498+ flat := flattenBlobs (tc .blobs )
499+ got , err := splitBlobs (flat )
500+ require .NoError (t , err )
501+ require .Equal (t , len (tc .blobs ), len (got ))
502+ for i , b := range got {
503+ expected := tc .blobs [i ]
504+ if expected == nil {
505+ expected = []byte {}
506+ }
507+ require .Equal (t , expected , b )
508+ }
509+ })
510+ }
511+ }
512+
513+ func TestFlattenBlobs_Empty (t * testing.T ) {
514+ require .Nil (t , flattenBlobs (nil ))
515+ require .Nil (t , flattenBlobs ([][]byte {}))
516+ }
517+
518+ func TestSplitBlobs_Empty (t * testing.T ) {
519+ got , err := splitBlobs (nil )
520+ require .NoError (t , err )
521+ require .Nil (t , got )
522+
523+ got , err = splitBlobs ([]byte {})
524+ require .NoError (t , err )
525+ require .Nil (t , got )
526+ }
527+
528+ func TestSplitBlobs_Truncated (t * testing.T ) {
529+ _ , err := splitBlobs ([]byte {0x01 })
530+ require .Error (t , err )
531+
532+ _ , err = splitBlobs ([]byte {0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 })
533+ require .Error (t , err )
534+ }
535+
536+ func TestSplitBlobs_CountMismatch (t * testing.T ) {
537+ data := []byte {0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 , 0x41 }
538+ _ , err := splitBlobs (data )
539+ require .Error (t , err )
540+ }
0 commit comments