Skip to content

Commit 86359c3

Browse files
committed
Review feedback
1 parent 6552a82 commit 86359c3

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

block/internal/da/async_block_retriever.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (f *asyncBlockRetriever) fetchAndCacheBlock(ctx context.Context, height uin
240240
Uint64("height", height).
241241
Str("status", result.Message).
242242
Msg("failed to retrieve block - will retry")
243+
return fmt.Errorf("retrieve block at height %d: %s", height, result.Message)
243244
}
244245
return nil
245246
}

block/internal/da/async_block_retriever_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,53 @@ func TestAsyncBlockRetriever_ReconnectOnSubscriptionError(t *testing.T) {
262262
assert.Equal(t, []byte("reconnect-tx"), block.Blobs[0])
263263
}
264264

265+
func TestAsyncBlockRetriever_FetchAndCacheBlock_ErrorResponse(t *testing.T) {
266+
fiNs := datypes.NamespaceFromString("test-fi-ns").Bytes()
267+
specs := map[string]struct {
268+
code datypes.StatusCode
269+
message string
270+
wantErr string
271+
}{
272+
"status_error": {
273+
code: datypes.StatusError,
274+
message: "rpc failure",
275+
wantErr: "retrieve block at height 123: rpc failure",
276+
},
277+
"status_context_deadline": {
278+
code: datypes.StatusContextDeadline,
279+
message: "timeout",
280+
wantErr: "retrieve block at height 123: timeout",
281+
},
282+
}
283+
284+
for name, spec := range specs {
285+
t.Run(name, func(t *testing.T) {
286+
client := &mocks.MockClient{}
287+
client.
288+
On("Retrieve", mock.Anything, uint64(123), fiNs).
289+
Return(datypes.ResultRetrieve{
290+
BaseResult: datypes.BaseResult{
291+
Code: spec.code,
292+
Message: spec.message,
293+
},
294+
}).
295+
Once()
296+
297+
logger := zerolog.Nop()
298+
fetcher := NewAsyncBlockRetriever(client, logger, fiNs, 100*time.Millisecond, 100, 10).(*asyncBlockRetriever)
299+
300+
err := fetcher.fetchAndCacheBlock(t.Context(), 123)
301+
require.EqualError(t, err, spec.wantErr)
302+
303+
block, getErr := fetcher.GetCachedBlock(t.Context(), 123)
304+
require.NoError(t, getErr)
305+
assert.Nil(t, block)
306+
307+
client.AssertExpectations(t)
308+
})
309+
}
310+
}
311+
265312
func TestBlockData_Serialization(t *testing.T) {
266313
block := &BlockData{
267314
Height: 100,

block/internal/syncing/syncer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,13 @@ func (s *Syncer) Stop(ctx context.Context) error {
236236
s.cancel()
237237
s.cancelP2PWait(0)
238238

239-
// Stop the DA follower first (it owns its own goroutines).
239+
if s.fiRetriever != nil {
240+
s.fiRetriever.Stop()
241+
}
242+
240243
if s.daFollower != nil {
241244
s.daFollower.Stop()
242245
}
243-
244246
s.wg.Wait()
245247

246248
// Skip draining if we're shutting down due to a critical error (e.g. execution

0 commit comments

Comments
 (0)