@@ -1062,3 +1062,89 @@ func TestSequencer_CheckpointPersistence_CrashRecovery(t *testing.T) {
10621062 t .Log ("✅ Checkpoint system successfully prevented re-execution of DA transactions after crash" )
10631063 mockFI .AssertExpectations (t )
10641064}
1065+
1066+ func TestSequencer_GetNextBatch_EmptyDABatch_IncreasesDAHeight (t * testing.T ) {
1067+ db := ds .NewMapDatastore ()
1068+ ctx := context .Background ()
1069+
1070+ mockRetriever := new (MockForcedInclusionRetriever )
1071+
1072+ // First DA epoch returns empty transactions
1073+ mockRetriever .On ("RetrieveForcedIncludedTxs" , mock .Anything , uint64 (100 )).
1074+ Return (& block.ForcedInclusionEvent {
1075+ Txs : [][]byte {},
1076+ StartDaHeight : 100 ,
1077+ EndDaHeight : 105 ,
1078+ }, nil ).Once ()
1079+
1080+ // Second DA epoch also returns empty transactions
1081+ mockRetriever .On ("RetrieveForcedIncludedTxs" , mock .Anything , uint64 (101 )).
1082+ Return (& block.ForcedInclusionEvent {
1083+ Txs : [][]byte {},
1084+ StartDaHeight : 106 ,
1085+ EndDaHeight : 111 ,
1086+ }, nil ).Once ()
1087+
1088+ gen := genesis.Genesis {
1089+ ChainID : "test" ,
1090+ DAStartHeight : 100 ,
1091+ DAEpochForcedInclusion : 5 ,
1092+ }
1093+
1094+ seq , err := NewSequencer (
1095+ ctx ,
1096+ zerolog .Nop (),
1097+ db ,
1098+ nil ,
1099+ []byte ("test" ),
1100+ 1 * time .Second ,
1101+ true ,
1102+ 1000 ,
1103+ mockRetriever ,
1104+ gen ,
1105+ )
1106+ require .NoError (t , err )
1107+
1108+ defer func () {
1109+ err := db .Close ()
1110+ if err != nil {
1111+ t .Fatalf ("Failed to close sequencer: %v" , err )
1112+ }
1113+ }()
1114+
1115+ req := coresequencer.GetNextBatchRequest {
1116+ Id : seq .Id ,
1117+ MaxBytes : 1000000 ,
1118+ LastBatchData : nil ,
1119+ }
1120+
1121+ // Initial DA height should be 100
1122+ assert .Equal (t , uint64 (100 ), seq .GetDAHeight ())
1123+ assert .Equal (t , uint64 (100 ), seq .checkpoint .DAHeight )
1124+
1125+ // First batch - empty DA block at height 100
1126+ resp , err := seq .GetNextBatch (ctx , req )
1127+ require .NoError (t , err )
1128+ require .NotNil (t , resp )
1129+ require .NotNil (t , resp .Batch )
1130+ assert .Equal (t , 0 , len (resp .Batch .Transactions ))
1131+
1132+ // DA height should have increased to 106 even though no transactions were processed
1133+ assert .Equal (t , uint64 (106 ), seq .GetDAHeight ())
1134+ assert .Equal (t , uint64 (106 ), seq .checkpoint .DAHeight )
1135+ assert .Equal (t , uint64 (0 ), seq .checkpoint .TxIndex )
1136+
1137+ // Second batch - empty DA block at height 106
1138+ resp , err = seq .GetNextBatch (ctx , req )
1139+ require .NoError (t , err )
1140+ require .NotNil (t , resp )
1141+ require .NotNil (t , resp .Batch )
1142+ assert .Equal (t , 0 , len (resp .Batch .Transactions ))
1143+
1144+ // DA height should have increased to 112
1145+ assert .Equal (t , uint64 (112 ), seq .GetDAHeight ())
1146+ assert .Equal (t , uint64 (112 ), seq .checkpoint .DAHeight )
1147+ assert .Equal (t , uint64 (0 ), seq .checkpoint .TxIndex )
1148+
1149+ mockRetriever .AssertExpectations (t )
1150+ }
0 commit comments