@@ -68,15 +68,13 @@ func setupManagerForSyncLoopTest(t *testing.T, initialState types.State) (
6868 dataStoreCh : dataStoreCh ,
6969 retrieveCh : retrieveCh ,
7070 daHeight : & atomic.Uint64 {},
71- lastPersistedDAHeight : & atomic.Uint64 {},
7271 metrics : NopMetrics (),
7372 headerStore : & goheaderstore.Store [* types.SignedHeader ]{},
7473 dataStore : & goheaderstore.Store [* types.Data ]{},
7574 signaturePayloadProvider : types .DefaultSignaturePayloadProvider ,
7675 validatorHasherProvider : types .DefaultValidatorHasherProvider ,
7776 }
7877 m .daHeight .Store (initialState .DAHeight )
79- m .lastPersistedDAHeight .Store (initialState .DAHeight )
8078
8179 ctx , cancel := context .WithCancel (context .Background ())
8280
@@ -135,6 +133,13 @@ func TestSyncLoop_ProcessSingleBlock_HeaderFirst(t *testing.T) {
135133 mockStore .On ("UpdateState" , mock .Anything , expectedNewState ).Return (nil ).Run (func (args mock.Arguments ) { close (syncChan ) }).Once ()
136134
137135 mockStore .On ("SetHeight" , mock .Anything , newHeight ).Return (nil ).Once ()
136+
137+ // Add expectations for DA inclusion metadata storage
138+ // These calls happen in storeDAInclusionMetadata when syncing blocks
139+ headerKey := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , newHeight )
140+ dataKey := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , newHeight )
141+ mockStore .On ("SetMetadata" , mock .Anything , headerKey , mock .Anything ).Return (nil ).Once ()
142+ mockStore .On ("SetMetadata" , mock .Anything , dataKey , mock .Anything ).Return (nil ).Once ()
138143
139144 ctx , loopCancel := context .WithTimeout (context .Background (), 1 * time .Second )
140145 defer loopCancel ()
@@ -220,6 +225,13 @@ func TestSyncLoop_ProcessSingleBlock_DataFirst(t *testing.T) {
220225 mockStore .On ("SaveBlockData" , mock .Anything , header , data , & header .Signature ).Return (nil ).Once ()
221226 mockStore .On ("UpdateState" , mock .Anything , expectedNewState ).Return (nil ).Run (func (args mock.Arguments ) { close (syncChan ) }).Once ()
222227 mockStore .On ("SetHeight" , mock .Anything , newHeight ).Return (nil ).Once ()
228+
229+ // Add expectations for DA inclusion metadata storage
230+ // These calls happen in storeDAInclusionMetadata when syncing blocks
231+ headerKey := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , newHeight )
232+ dataKey := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , newHeight )
233+ mockStore .On ("SetMetadata" , mock .Anything , headerKey , mock .Anything ).Return (nil ).Once ()
234+ mockStore .On ("SetMetadata" , mock .Anything , dataKey , mock .Anything ).Return (nil ).Once ()
223235
224236 ctx , loopCancel := context .WithTimeout (context .Background (), 1 * time .Second )
225237 defer loopCancel ()
@@ -331,6 +343,12 @@ func TestSyncLoop_ProcessMultipleBlocks_Sequentially(t *testing.T) {
331343 t .Logf ("Mock SetHeight called for H+1, updated mock height to %d" , newHeight )
332344 }).
333345 Once ()
346+
347+ // Add expectations for DA inclusion metadata storage for H+1
348+ headerKeyH1 := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , heightH1 )
349+ dataKeyH1 := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , heightH1 )
350+ mockStore .On ("SetMetadata" , mock .Anything , headerKeyH1 , mock .Anything ).Return (nil ).Once ()
351+ mockStore .On ("SetMetadata" , mock .Anything , dataKeyH1 , mock .Anything ).Return (nil ).Once ()
334352
335353 // --- Mock Expectations for H+2 ---
336354 mockExec .On ("ExecuteTxs" , mock .Anything , txsH2 , heightH2 , headerH2 .Time (), expectedNewAppHashH1 ).
@@ -344,6 +362,12 @@ func TestSyncLoop_ProcessMultipleBlocks_Sequentially(t *testing.T) {
344362 t .Logf ("Mock SetHeight called for H+2, updated mock height to %d" , newHeight )
345363 }).
346364 Once ()
365+
366+ // Add expectations for DA inclusion metadata storage for H+2
367+ headerKeyH2 := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , heightH2 )
368+ dataKeyH2 := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , heightH2 )
369+ mockStore .On ("SetMetadata" , mock .Anything , headerKeyH2 , mock .Anything ).Return (nil ).Once ()
370+ mockStore .On ("SetMetadata" , mock .Anything , dataKeyH2 , mock .Anything ).Return (nil ).Once ()
347371
348372 ctx , loopCancel := context .WithTimeout (context .Background (), 1 * time .Second )
349373 defer loopCancel ()
@@ -469,9 +493,15 @@ func TestSyncLoop_ProcessBlocks_OutOfOrderArrival(t *testing.T) {
469493 Run (func (args mock.Arguments ) {
470494 newHeight := args .Get (1 ).(uint64 )
471495 * heightPtr = newHeight // Update the mocked height
472- t .Logf ("Mock SetHeight called for H+2 , updated mock height to %d" , newHeight )
496+ t .Logf ("Mock SetHeight called for H+1 , updated mock height to %d" , newHeight )
473497 }).
474498 Once ()
499+
500+ // Add expectations for DA inclusion metadata storage for H+1
501+ headerKeyH1 := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , heightH1 )
502+ dataKeyH1 := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , heightH1 )
503+ mockStore .On ("SetMetadata" , mock .Anything , headerKeyH1 , mock .Anything ).Return (nil ).Once ()
504+ mockStore .On ("SetMetadata" , mock .Anything , dataKeyH1 , mock .Anything ).Return (nil ).Once ()
475505
476506 // --- Mock Expectations for H+2 (will be called second) ---
477507 mockStore .On ("Height" , mock .Anything ).Return (heightH1 , nil ).Maybe ()
@@ -489,6 +519,12 @@ func TestSyncLoop_ProcessBlocks_OutOfOrderArrival(t *testing.T) {
489519 mockStore .On ("UpdateState" , mock .Anything , expectedStateH2 ).Return (nil ).
490520 Run (func (args mock.Arguments ) { close (syncChanH2 ) }).
491521 Once ()
522+
523+ // Add expectations for DA inclusion metadata storage for H+2
524+ headerKeyH2 := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , heightH2 )
525+ dataKeyH2 := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , heightH2 )
526+ mockStore .On ("SetMetadata" , mock .Anything , headerKeyH2 , mock .Anything ).Return (nil ).Once ()
527+ mockStore .On ("SetMetadata" , mock .Anything , dataKeyH2 , mock .Anything ).Return (nil ).Once ()
492528
493529 ctx , loopCancel := context .WithTimeout (context .Background (), 1 * time .Second )
494530 defer loopCancel ()
@@ -598,6 +634,13 @@ func TestSyncLoop_IgnoreDuplicateEvents(t *testing.T) {
598634 mockStore .On ("UpdateState" , mock .Anything , expectedStateH1 ).Return (nil ).
599635 Run (func (args mock.Arguments ) { close (syncChanH1 ) }).
600636 Once ()
637+
638+ // Add expectations for DA inclusion metadata storage
639+ // These calls happen in storeDAInclusionMetadata when syncing blocks
640+ headerKey := fmt .Sprintf ("%s/%d/h" , store .HeightToDAHeightKey , heightH1 )
641+ dataKey := fmt .Sprintf ("%s/%d/d" , store .HeightToDAHeightKey , heightH1 )
642+ mockStore .On ("SetMetadata" , mock .Anything , headerKey , mock .Anything ).Return (nil ).Once ()
643+ mockStore .On ("SetMetadata" , mock .Anything , dataKey , mock .Anything ).Return (nil ).Once ()
601644
602645 ctx , loopCancel := context .WithTimeout (context .Background (), 1 * time .Second )
603646 defer loopCancel ()
@@ -875,13 +918,11 @@ func TestSyncLoop_MultipleHeadersArriveFirst_ThenData(t *testing.T) {
875918 headerInCh : headerInCh ,
876919 dataInCh : dataInCh ,
877920 daHeight : & atomic.Uint64 {},
878- lastPersistedDAHeight : & atomic.Uint64 {},
879921 metrics : NopMetrics (),
880922 signaturePayloadProvider : types .DefaultSignaturePayloadProvider ,
881923 validatorHasherProvider : types .DefaultValidatorHasherProvider ,
882924 }
883925 m .daHeight .Store (initialState .DAHeight )
884- m .lastPersistedDAHeight .Store (initialState .DAHeight )
885926
886927 ctx , loopCancel := context .WithTimeout (context .Background (), 2 * time .Second )
887928 defer loopCancel ()
0 commit comments