@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/stretchr/testify/assert"
1212 "github.com/stretchr/testify/mock"
13+ "go.uber.org/zap"
1314
1415 coreda "github.com/evstack/ev-node/core/da"
1516 "github.com/evstack/ev-node/core/sequencer"
@@ -20,24 +21,10 @@ import (
2021)
2122
2223// newTestManager creates a Manager with mocked Store and Executor for testing DAIncluder logic.
23- func newTestManager (t * testing.T ) (* Manager , * mocks.MockStore , * mocks.MockExecutor , * MockLogger ) {
24+ func newTestManager (t * testing.T ) (* Manager , * mocks.MockStore , * mocks.MockExecutor , * zap. Logger ) {
2425 store := mocks .NewMockStore (t )
2526 exec := mocks .NewMockExecutor (t )
26- logger := new (MockLogger )
27-
28- // Allow logging calls with message string and optional key-value pairs (up to 2 pairs / 4 args for simplicity)
29- logger .On ("Debug" , mock .AnythingOfType ("string" )).Maybe ()
30- logger .On ("Debug" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything ).Maybe ()
31- logger .On ("Debug" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Maybe ()
32- logger .On ("Info" , mock .AnythingOfType ("string" )).Maybe ()
33- logger .On ("Info" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything ).Maybe ()
34- logger .On ("Info" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Maybe ()
35- logger .On ("Warn" , mock .AnythingOfType ("string" )).Maybe ()
36- logger .On ("Warn" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything ).Maybe ()
37- logger .On ("Warn" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Maybe ()
38- logger .On ("Error" , mock .AnythingOfType ("string" )).Maybe ()
39- logger .On ("Error" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything ).Maybe ()
40- logger .On ("Error" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Maybe ()
27+ logger := zap .NewNop () // Use no-op logger for tests
4128
4229 // Mock Height to always return a high value so IsDAIncluded works
4330 store .On ("Height" , mock .Anything ).Return (uint64 (100 ), nil ).Maybe ()
@@ -171,20 +158,17 @@ func TestDAIncluderLoop_StopsWhenDataNotDAIncluded(t *testing.T) {
171158// if GetBlockData returns an error for the next block height.
172159func TestDAIncluderLoop_StopsOnGetBlockDataError (t * testing.T ) {
173160 t .Parallel ()
174- m , store , _ , mockLogger := newTestManager (t )
161+ m , store , _ , _ := newTestManager (t )
175162 startDAIncludedHeight := uint64 (4 )
176163 m .daIncludedHeight .Store (startDAIncludedHeight )
177164
178165 store .On ("GetBlockData" , mock .Anything , uint64 (5 )).Return (nil , nil , assert .AnError ).Once ()
179166
180167 // Expect the debug log for no more blocks to check
181- mockLogger . ExpectedCalls = nil // Clear any previous expectations for specific checks
168+
182169 // Re-establish general Maybe calls after clearing, then specific Once call
183- mockLogger .On ("Debug" , mock .AnythingOfType ("string" )).Maybe ()
184- mockLogger .On ("Debug" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything ).Maybe ()
185- mockLogger .On ("Debug" , mock .AnythingOfType ("string" ), mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Maybe ()
170+
186171 // Add other Maybe calls if Info/Warn/Error might also occur and are not asserted
187- mockLogger .On ("Info" , mock .AnythingOfType ("string" )).Maybe ()
188172
189173 ctx , loopCancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
190174 defer loopCancel ()
@@ -201,7 +185,7 @@ func TestDAIncluderLoop_StopsOnGetBlockDataError(t *testing.T) {
201185
202186 assert .Equal (t , startDAIncludedHeight , m .GetDAIncludedHeight ())
203187 store .AssertExpectations (t )
204- mockLogger . AssertExpectations ( t )
188+
205189}
206190
207191// TestIncrementDAIncludedHeight_Success verifies that incrementDAIncludedHeight increments the height
@@ -229,7 +213,7 @@ func TestIncrementDAIncludedHeight_Success(t *testing.T) {
229213// if SetMetadata fails after SetFinal succeeds.
230214func TestIncrementDAIncludedHeight_SetMetadataError (t * testing.T ) {
231215 t .Parallel ()
232- m , store , exec , mockLogger := newTestManager (t )
216+ m , store , exec , _ := newTestManager (t )
233217 startDAIncludedHeight := uint64 (4 )
234218 expectedDAIncludedHeight := startDAIncludedHeight + 1
235219 m .daIncludedHeight .Store (startDAIncludedHeight )
@@ -243,14 +227,14 @@ func TestIncrementDAIncludedHeight_SetMetadataError(t *testing.T) {
243227 assert .Error (t , err )
244228 store .AssertExpectations (t )
245229 exec .AssertExpectations (t )
246- mockLogger . AssertExpectations ( t )
230+
247231}
248232
249233// TestIncrementDAIncludedHeight_SetFinalError verifies that incrementDAIncludedHeight returns an error
250234// if SetFinal fails before SetMetadata, and logs the error.
251235func TestIncrementDAIncludedHeight_SetFinalError (t * testing.T ) {
252236 t .Parallel ()
253- m , store , exec , mockLogger := newTestManager (t )
237+ m , store , exec , _ := newTestManager (t )
254238 startDAIncludedHeight := uint64 (4 )
255239 expectedDAIncludedHeight := startDAIncludedHeight + 1
256240 m .daIncludedHeight .Store (startDAIncludedHeight )
@@ -263,7 +247,7 @@ func TestIncrementDAIncludedHeight_SetFinalError(t *testing.T) {
263247 assert .Error (t , err )
264248 exec .AssertExpectations (t )
265249 store .AssertExpectations (t )
266- mockLogger . AssertExpectations ( t )
250+
267251}
268252
269253// TestDAIncluderLoop_MultipleConsecutiveHeightsDAIncluded verifies that DAIncluderLoop advances the height
0 commit comments