@@ -648,22 +648,22 @@ func TestJoinerReadAt(t *testing.T) {
648648
649649 // create root chunk with 2 references and the referenced data chunks
650650 rootChunk := filetest .GenerateTestRandomFileChunk (swarm .ZeroAddress , swarm .ChunkSize * 2 , swarm .SectionSize * 2 )
651- err := store . Put ( ctx , rootChunk )
652- if err != nil {
651+
652+ if err := store . Put ( ctx , rootChunk ); err != nil {
653653 t .Fatal (err )
654654 }
655655
656656 firstAddress := swarm .NewAddress (rootChunk .Data ()[8 : swarm .SectionSize + 8 ])
657657 firstChunk := filetest .GenerateTestRandomFileChunk (firstAddress , swarm .ChunkSize , swarm .ChunkSize )
658- err = store . Put ( ctx , firstChunk )
659- if err != nil {
658+
659+ if err := store . Put ( ctx , firstChunk ); err != nil {
660660 t .Fatal (err )
661661 }
662662
663663 secondAddress := swarm .NewAddress (rootChunk .Data ()[swarm .SectionSize + 8 :])
664664 secondChunk := filetest .GenerateTestRandomFileChunk (secondAddress , swarm .ChunkSize , swarm .ChunkSize )
665- err = store . Put ( ctx , secondChunk )
666- if err != nil {
665+
666+ if err := store . Put ( ctx , secondChunk ); err != nil {
667667 t .Fatal (err )
668668 }
669669
@@ -673,8 +673,8 @@ func TestJoinerReadAt(t *testing.T) {
673673 }
674674
675675 b := make ([]byte , swarm .ChunkSize )
676- _ , err = j . ReadAt ( b , swarm . ChunkSize )
677- if err != nil {
676+
677+ if _ , err = j . ReadAt ( b , swarm . ChunkSize ); err != nil {
678678 t .Fatal (err )
679679 }
680680
@@ -685,7 +685,8 @@ func TestJoinerReadAt(t *testing.T) {
685685}
686686
687687// TestJoinerOneLevel tests the retrieval of two data chunks immediately
688- // below the root chunk level.
688+ // below the root chunk level. It verifies that the joiner correctly reads
689+ // and returns data from both chunks in sequence and handles EOF properly.
689690func TestJoinerOneLevel (t * testing.T ) {
690691 synctest .Test (t , func (t * testing.T ) {
691692 store := inmemchunkstore .New ()
@@ -695,22 +696,19 @@ func TestJoinerOneLevel(t *testing.T) {
695696
696697 // create root chunk with 2 references and the referenced data chunks
697698 rootChunk := filetest .GenerateTestRandomFileChunk (swarm .ZeroAddress , swarm .ChunkSize * 2 , swarm .SectionSize * 2 )
698- err := store .Put (ctx , rootChunk )
699- if err != nil {
699+ if err := store .Put (ctx , rootChunk ); err != nil {
700700 t .Fatal (err )
701701 }
702702
703703 firstAddress := swarm .NewAddress (rootChunk .Data ()[8 : swarm .SectionSize + 8 ])
704704 firstChunk := filetest .GenerateTestRandomFileChunk (firstAddress , swarm .ChunkSize , swarm .ChunkSize )
705- err = store .Put (ctx , firstChunk )
706- if err != nil {
705+ if err := store .Put (ctx , firstChunk ); err != nil {
707706 t .Fatal (err )
708707 }
709708
710709 secondAddress := swarm .NewAddress (rootChunk .Data ()[swarm .SectionSize + 8 :])
711710 secondChunk := filetest .GenerateTestRandomFileChunk (secondAddress , swarm .ChunkSize , swarm .ChunkSize )
712- err = store .Put (ctx , secondChunk )
713- if err != nil {
711+ if err := store .Put (ctx , secondChunk ); err != nil {
714712 t .Fatal (err )
715713 }
716714
@@ -745,13 +743,11 @@ func TestJoinerOneLevel(t *testing.T) {
745743 }
746744
747745 // verify EOF is returned also after first time it is returned
748- _ , err = j .Read (outBuffer )
749- if ! errors .Is (err , io .EOF ) {
746+ if _ , err = j .Read (outBuffer ); ! errors .Is (err , io .EOF ) {
750747 t .Fatal ("expected io.EOF" )
751748 }
752749
753- _ , err = j .Read (outBuffer )
754- if ! errors .Is (err , io .EOF ) {
750+ if _ , err = j .Read (outBuffer ); ! errors .Is (err , io .EOF ) {
755751 t .Fatal ("expected io.EOF" )
756752 }
757753 })
@@ -769,22 +765,19 @@ func TestJoinerTwoLevelsAcrossChunk(t *testing.T) {
769765
770766 // create root chunk with 2 references and two intermediate chunks with references
771767 rootChunk := filetest .GenerateTestRandomFileChunk (swarm .ZeroAddress , swarm .ChunkSize * swarm .Branches + 42 , swarm .SectionSize * 2 )
772- err := store .Put (ctx , rootChunk )
773- if err != nil {
768+ if err := store .Put (ctx , rootChunk ); err != nil {
774769 t .Fatal (err )
775770 }
776771
777772 firstAddress := swarm .NewAddress (rootChunk .Data ()[8 : swarm .SectionSize + 8 ])
778773 firstChunk := filetest .GenerateTestRandomFileChunk (firstAddress , swarm .ChunkSize * swarm .Branches , swarm .ChunkSize )
779- err = store .Put (ctx , firstChunk )
780- if err != nil {
774+ if err := store .Put (ctx , firstChunk ); err != nil {
781775 t .Fatal (err )
782776 }
783777
784778 secondAddress := swarm .NewAddress (rootChunk .Data ()[swarm .SectionSize + 8 :])
785779 secondChunk := filetest .GenerateTestRandomFileChunk (secondAddress , 42 , swarm .SectionSize )
786- err = store .Put (ctx , secondChunk )
787- if err != nil {
780+ if err := store .Put (ctx , secondChunk ); err != nil {
788781 t .Fatal (err )
789782 }
790783
@@ -794,17 +787,15 @@ func TestJoinerTwoLevelsAcrossChunk(t *testing.T) {
794787 chunkAddressBytes := firstChunk .Data ()[cursor : cursor + swarm .SectionSize ]
795788 chunkAddress := swarm .NewAddress (chunkAddressBytes )
796789 ch := filetest .GenerateTestRandomFileChunk (chunkAddress , swarm .ChunkSize , swarm .ChunkSize )
797- err := store .Put (ctx , ch )
798- if err != nil {
790+ if err := store .Put (ctx , ch ); err != nil {
799791 t .Fatal (err )
800792 }
801793 cursor += swarm .SectionSize
802794 }
803795 chunkAddressBytes := secondChunk .Data ()[8 :]
804796 chunkAddress := swarm .NewAddress (chunkAddressBytes )
805797 ch := filetest .GenerateTestRandomFileChunk (chunkAddress , 42 , 42 )
806- err = store .Put (ctx , ch )
807- if err != nil {
798+ if err := store .Put (ctx , ch ); err != nil {
808799 t .Fatal (err )
809800 }
810801
@@ -843,22 +834,19 @@ func TestJoinerIterateChunkAddresses(t *testing.T) {
843834
844835 // create root chunk with 2 references and the referenced data chunks
845836 rootChunk := filetest .GenerateTestRandomFileChunk (swarm .ZeroAddress , swarm .ChunkSize * 2 , swarm .SectionSize * 2 )
846- err := store .Put (ctx , rootChunk )
847- if err != nil {
837+ if err := store .Put (ctx , rootChunk ); err != nil {
848838 t .Fatal (err )
849839 }
850840
851841 firstAddress := swarm .NewAddress (rootChunk .Data ()[8 : swarm .SectionSize + 8 ])
852842 firstChunk := filetest .GenerateTestRandomFileChunk (firstAddress , swarm .ChunkSize , swarm .ChunkSize )
853- err = store .Put (ctx , firstChunk )
854- if err != nil {
843+ if err := store .Put (ctx , firstChunk ); err != nil {
855844 t .Fatal (err )
856845 }
857846
858847 secondAddress := swarm .NewAddress (rootChunk .Data ()[swarm .SectionSize + 8 :])
859848 secondChunk := filetest .GenerateTestRandomFileChunk (secondAddress , swarm .ChunkSize , swarm .ChunkSize )
860- err = store .Put (ctx , secondChunk )
861- if err != nil {
849+ if err := store .Put (ctx , secondChunk ); err != nil {
862850 t .Fatal (err )
863851 }
864852
@@ -1333,8 +1321,7 @@ func runRedundancyTest(t *testing.T, rLevel redundancy.Level, encrypt bool, size
13331321 if n != expRead {
13341322 t .Errorf ("read %d bytes out of %d" , n , expRead )
13351323 }
1336- _ , err = dataReader .Seek (int64 (offset ), io .SeekStart )
1337- if err != nil {
1324+ if _ , err = dataReader .Seek (int64 (offset ), io .SeekStart ); err != nil {
13381325 t .Fatal (err )
13391326 }
13401327 ok , err := dataReader .Match (bytes .NewBuffer (buf ), expRead )
0 commit comments