diff --git a/access/grpc/grpc.go b/access/grpc/grpc.go index 1d0aed61f..fea0d35bf 100644 --- a/access/grpc/grpc.go +++ b/access/grpc/grpc.go @@ -1408,9 +1408,14 @@ func (c *BaseClient) SubscribeBlockDigestsFromStartHeight( blockStatus flow.BlockStatus, opts ...grpc.CallOption, ) (<-chan flow.BlockDigest, <-chan error, error) { + status := convert.BlockStatusToEntity(blockStatus) + if status == entities.BlockStatus_BLOCK_UNKNOWN { + return nil, nil, newRPCError(errors.New("unknown block status")) + } + request := &access.SubscribeBlockDigestsFromStartHeightRequest{ StartBlockHeight: startHeight, - BlockStatus: convert.BlockStatusToEntity(blockStatus), + BlockStatus: status, } subscribeClient, err := c.rpcClient.SubscribeBlockDigestsFromStartHeight(ctx, request, opts...) @@ -1435,8 +1440,13 @@ func (c *BaseClient) SubscribeBlockDigestsFromLatest( blockStatus flow.BlockStatus, opts ...grpc.CallOption, ) (<-chan flow.BlockDigest, <-chan error, error) { + status := convert.BlockStatusToEntity(blockStatus) + if status == entities.BlockStatus_BLOCK_UNKNOWN { + return nil, nil, newRPCError(errors.New("unknown block status")) + } + request := &access.SubscribeBlockDigestsFromLatestRequest{ - BlockStatus: convert.BlockStatusToEntity(blockStatus), + BlockStatus: status, } subscribeClient, err := c.rpcClient.SubscribeBlockDigestsFromLatest(ctx, request, opts...) diff --git a/access/grpc/grpc_test.go b/access/grpc/grpc_test.go index 975a0d4f2..09e5534a3 100644 --- a/access/grpc/grpc_test.go +++ b/access/grpc/grpc_test.go @@ -2571,7 +2571,7 @@ func TestClient_SubscribeBlockDigest(t *testing.T) { On("SubscribeBlockDigestsFromStartHeight", ctx, mock.Anything). Return(stream, nil) - blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromStartHeight(ctx, startHeight, flow.BlockStatusUnknown) + blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromStartHeight(ctx, startHeight, flow.BlockStatusSealed) require.NoError(t, err) wg := sync.WaitGroup{} @@ -2602,7 +2602,7 @@ func TestClient_SubscribeBlockDigest(t *testing.T) { Return(stream, nil) startBlockID := convert.MessageToIdentifier(stream.responses[0].BlockId) - blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromStartBlockID(ctx, startBlockID, flow.BlockStatusUnknown) + blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromStartBlockID(ctx, startBlockID, flow.BlockStatusSealed) require.NoError(t, err) wg := sync.WaitGroup{} @@ -2632,7 +2632,7 @@ func TestClient_SubscribeBlockDigest(t *testing.T) { On("SubscribeBlockDigestsFromLatest", ctx, mock.Anything). Return(stream, nil) - blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromLatest(ctx, flow.BlockStatusUnknown) + blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromLatest(ctx, flow.BlockStatusSealed) require.NoError(t, err) wg := sync.WaitGroup{} @@ -2660,7 +2660,7 @@ func TestClient_SubscribeBlockDigest(t *testing.T) { On("SubscribeBlockDigestsFromLatest", ctx, mock.Anything). Return(stream, nil) - blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromLatest(ctx, flow.BlockStatusUnknown) + blockDigestsCh, errCh, err := c.SubscribeBlockDigestsFromLatest(ctx, flow.BlockStatusSealed) require.NoError(t, err) wg := sync.WaitGroup{}