@@ -167,12 +167,13 @@ func TestBasedSequencer_GetNextBatch_EmptyDA(t *testing.T) {
167167 LastBatchData : nil ,
168168 }
169169
170+ // Empty epoch has no valid txs — sequencer returns ErrNoBatch
170171 resp , err := seq .GetNextBatch (context .Background (), req )
171- require .NoError (t , err )
172- require .NotNil (t , resp )
173- require . NotNil ( t , resp . Batch )
174- // Should return empty batch when DA has no transactions
175- assert .Equal (t , 0 , len ( resp . Batch . Transactions ) )
172+ require .ErrorIs (t , err , block . ErrNoBatch )
173+ require .Nil (t , resp )
174+
175+ // Checkpoint should still advance past the empty epoch
176+ assert .Equal (t , uint64 ( 101 ), seq . checkpoint . DAHeight )
176177
177178 mockRetriever .AssertExpectations (t )
178179}
@@ -339,12 +340,13 @@ func TestBasedSequencer_GetNextBatch_ForcedInclusionExceedsMaxBytes(t *testing.T
339340 LastBatchData : nil ,
340341 }
341342
343+ // All txs are skipped due to size — sequencer returns ErrNoBatch
342344 resp , err := seq .GetNextBatch (context .Background (), req )
343- require .NoError (t , err )
344- require .NotNil (t , resp )
345- require . NotNil ( t , resp . Batch )
346- // Should return empty batch since transaction exceeds max bytes
347- assert .Equal (t , 0 , len ( resp . Batch . Transactions ) )
345+ require .ErrorIs (t , err , block . ErrNoBatch )
346+ require .Nil (t , resp )
347+
348+ // Checkpoint should still advance past the epoch with the oversized tx
349+ assert .Equal (t , uint64 ( 101 ), seq . checkpoint . DAHeight )
348350
349351 mockRetriever .AssertExpectations (t )
350352}
@@ -430,13 +432,12 @@ func TestBasedSequencer_GetNextBatch_HeightFromFuture(t *testing.T) {
430432 LastBatchData : nil ,
431433 }
432434
433- // Should not error, but return empty batch
435+ // DA hasn't produced that block yet — sequencer returns ErrNoBatch
434436 resp , err := seq .GetNextBatch (context .Background (), req )
435- require .NoError (t , err )
436- require .NotNil (t , resp )
437- assert .Equal (t , 0 , len (resp .Batch .Transactions ))
437+ require .ErrorIs (t , err , block .ErrNoBatch )
438+ require .Nil (t , resp )
438439
439- // DA height should stay the same
440+ // DA height should stay the same — checkpoint must not advance
440441 assert .Equal (t , uint64 (100 ), seq .checkpoint .DAHeight )
441442
442443 mockRetriever .AssertExpectations (t )
@@ -665,24 +666,21 @@ func TestBasedSequencer_GetNextBatch_EmptyDABatch_IncreasesDAHeight(t *testing.T
665666 assert .Equal (t , uint64 (100 ), seq .GetDAHeight ())
666667 assert .Equal (t , uint64 (100 ), seq .checkpoint .DAHeight )
667668
668- // First batch - empty DA block at height 100
669+ // First call — empty DA epoch at height 100, no txs → ErrNoBatch.
670+ // Checkpoint must still advance so the next call moves to epoch 101.
669671 resp , err := seq .GetNextBatch (context .Background (), req )
670- require .NoError (t , err )
671- require .NotNil (t , resp )
672- require .NotNil (t , resp .Batch )
673- assert .Equal (t , 0 , len (resp .Batch .Transactions ))
672+ require .ErrorIs (t , err , block .ErrNoBatch )
673+ require .Nil (t , resp )
674674
675675 // DA height should have increased to 101 even though no transactions were processed
676676 assert .Equal (t , uint64 (101 ), seq .GetDAHeight ())
677677 assert .Equal (t , uint64 (101 ), seq .checkpoint .DAHeight )
678678 assert .Equal (t , uint64 (0 ), seq .checkpoint .TxIndex )
679679
680- // Second batch - empty DA block at height 101
680+ // Second call — empty DA epoch at height 101, no txs → ErrNoBatch.
681681 resp , err = seq .GetNextBatch (context .Background (), req )
682- require .NoError (t , err )
683- require .NotNil (t , resp )
684- require .NotNil (t , resp .Batch )
685- assert .Equal (t , 0 , len (resp .Batch .Transactions ))
682+ require .ErrorIs (t , err , block .ErrNoBatch )
683+ require .Nil (t , resp )
686684
687685 // DA height should have increased to 102
688686 assert .Equal (t , uint64 (102 ), seq .GetDAHeight ())
@@ -801,7 +799,8 @@ func TestBasedSequencer_GetNextBatch_TimestampAdjustment_PartialBatch(t *testing
801799}
802800
803801func TestBasedSequencer_GetNextBatch_TimestampAdjustment_EmptyBatch (t * testing.T ) {
804- // Test that timestamp is zero when batch is empty
802+ // Test that an empty DA epoch returns ErrNoBatch (no valid txs to include).
803+ // The checkpoint must still advance past the empty epoch.
805804 daEndTime := time .Date (2024 , 1 , 1 , 12 , 0 , 0 , 0 , time .UTC )
806805
807806 mockRetriever := common .NewMockForcedInclusionRetriever (t )
@@ -825,15 +824,13 @@ func TestBasedSequencer_GetNextBatch_TimestampAdjustment_EmptyBatch(t *testing.T
825824 LastBatchData : nil ,
826825 }
827826
827+ // Empty epoch — no valid txs, sequencer returns ErrNoBatch
828828 resp , err := seq .GetNextBatch (context .Background (), req )
829- require .NoError (t , err )
830- require .NotNil (t , resp )
831- require .NotNil (t , resp .Batch )
832- assert .Equal (t , 0 , len (resp .Batch .Transactions ))
829+ require .ErrorIs (t , err , block .ErrNoBatch )
830+ require .Nil (t , resp )
833831
834- // When batch is empty, there are 0 remaining txs, so timestamp = daEndTime
835- expectedTimestamp := daEndTime
836- assert .Equal (t , expectedTimestamp , resp .Timestamp )
832+ // Checkpoint must have advanced so the next call moves past this epoch
833+ assert .Equal (t , uint64 (101 ), seq .checkpoint .DAHeight )
837834
838835 mockRetriever .AssertExpectations (t )
839836}
0 commit comments