Skip to content

Commit 3b4fe3f

Browse files
committed
Fix dummyDA
1 parent e444215 commit 3b4fe3f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/testda/dummy.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ func (d *DummyDA) Submit(_ context.Context, data [][]byte, _ float64, namespace
126126

127127
// Retrieve returns blobs stored at the given height and namespace.
128128
func (d *DummyDA) Retrieve(_ context.Context, height uint64, namespace []byte) datypes.ResultRetrieve {
129+
h := d.height.Load()
130+
if height > h {
131+
return datypes.ResultRetrieve{
132+
BaseResult: datypes.BaseResult{
133+
Code: datypes.StatusHeightFromFuture,
134+
Message: datypes.ErrHeightFromFuture.Error(),
135+
},
136+
}
137+
}
138+
129139
d.mu.Lock()
130140
byHeight := d.blobs[height]
131141
var blobs [][]byte
@@ -208,17 +218,16 @@ func (d *DummyDA) SetHeight(h uint64) {
208218
d.height.Store(h)
209219
}
210220

211-
// StartHeightTicker starts a goroutine that increments height at the given interval.
212-
// Returns a stop function that should be called to stop the ticker.
221+
// StartHeightTicker starts a goroutine that increments the height every interval.
222+
// It returns a function to stop the ticker.
213223
func (d *DummyDA) StartHeightTicker(interval time.Duration) func() {
214224
if interval == 0 {
215225
return func() {}
216226
}
217-
218227
d.tickerMu.Lock()
219228
if d.tickerStop != nil {
220229
d.tickerMu.Unlock()
221-
return func() {} // already running
230+
return func() {}
222231
}
223232
d.tickerStop = make(chan struct{})
224233
stopCh := d.tickerStop

0 commit comments

Comments
 (0)