Skip to content

Commit 907c708

Browse files
committed
Fixed msg index start from 0
1 parent f419a5c commit 907c708

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

engine/access/rest/websockets/data_providers/account_statuses_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ func (p *AccountStatusesDataProvider) handleResponse() func(accountStatusesRespo
111111
blocksSinceLastMessage = 0
112112
}
113113

114+
index := messageIndex.Value()
114115
if ok := messageIndex.Set(messageIndex.Value() + 1); !ok {
115116
return status.Errorf(codes.Internal, "message index already incremented to %d", messageIndex.Value())
116117
}
117-
index := messageIndex.Value()
118118

119119
p.send <- &models.AccountStatusesResponse{
120120
BlockID: accountStatusesResponse.BlockID.String(),

engine/access/rest/websockets/data_providers/account_statuses_provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ func (s *AccountStatusesProviderSuite) TestMessageIndexAccountStatusesProviderRe
254254
responses = append(responses, accountStatusesRes)
255255
}
256256

257-
// Verifying that indices are starting from 1
258-
s.Require().Equal(uint64(1), responses[0].MessageIndex, "Expected MessageIndex to start with 1")
257+
// Verifying that indices are starting from 0
258+
s.Require().Equal(uint64(0), responses[0].MessageIndex, "Expected MessageIndex to start with 0")
259259

260260
// Verifying that indices are strictly increasing
261261
for i := 1; i < len(responses); i++ {

engine/access/rest/websockets/data_providers/events_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ func (p *EventsDataProvider) handleResponse() func(eventsResponse *backend.Event
9797
blocksSinceLastMessage = 0
9898
}
9999

100+
index := messageIndex.Value()
100101
if ok := messageIndex.Set(messageIndex.Value() + 1); !ok {
101102
return fmt.Errorf("message index already incremented to: %d", messageIndex.Value())
102103
}
103-
index := messageIndex.Value()
104104

105105
p.send <- &models.EventResponse{
106106
BlockId: eventsResponse.BlockID.String(),

engine/access/rest/websockets/data_providers/events_provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (s *EventsProviderSuite) TestMessageIndexEventProviderResponse_HappyPath()
282282
}
283283

284284
// Verifying that indices are starting from 1
285-
s.Require().Equal(uint64(1), responses[0].MessageIndex, "Expected MessageIndex to start with 1")
285+
s.Require().Equal(uint64(0), responses[0].MessageIndex, "Expected MessageIndex to start with 0")
286286

287287
// Verifying that indices are strictly increasing
288288
for i := 1; i < len(responses); i++ {

0 commit comments

Comments
 (0)