Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit a3a18fb

Browse files
authored
Fix x86 tests (#3317)
x86 tests broke with #3298 (Not exactly the tests modified here, but `TestMessageHistoryVisibility`)
1 parent 87f028d commit a3a18fb

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

syncapi/types/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ func NewTopologyTokenFromString(tok string) (token TopologyToken, err error) {
286286
if i > len(positions) {
287287
break
288288
}
289-
var pos int
290-
pos, err = strconv.Atoi(p)
289+
var pos int64
290+
pos, err = strconv.ParseInt(p, 10, 64)
291291
if err != nil {
292292
return
293293
}
@@ -318,8 +318,8 @@ func NewStreamTokenFromString(tok string) (token StreamingToken, err error) {
318318
if i >= len(positions) {
319319
break
320320
}
321-
var pos int
322-
pos, err = strconv.Atoi(p)
321+
var pos int64
322+
pos, err = strconv.ParseInt(p, 10, 64)
323323
if err != nil {
324324
err = ErrMalformedSyncToken
325325
return

syncapi/types/types_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package types
33
import (
44
"context"
55
"encoding/json"
6+
"math"
67
"reflect"
78
"testing"
89

@@ -33,12 +34,28 @@ func TestSyncTokens(t *testing.T) {
3334
"s3_1_0_0_0_0_2_0_5": StreamingToken{3, 1, 0, 0, 0, 0, 2, 0, 5}.String(),
3435
"s3_1_2_3_5_0_0_0_6": StreamingToken{3, 1, 2, 3, 5, 0, 0, 0, 6}.String(),
3536
"t3_1": TopologyToken{3, 1}.String(),
37+
"t9223372036854775807_9223372036854775807": TopologyToken{Depth: math.MaxInt64, PDUPosition: math.MaxInt64}.String(),
38+
"s9223372036854775807_1_2_3_5_0_0_0_6": StreamingToken{math.MaxInt64, 1, 2, 3, 5, 0, 0, 0, 6}.String(),
3639
}
3740

3841
for a, b := range shouldPass {
3942
if a != b {
4043
t.Errorf("expected %q, got %q", a, b)
4144
}
45+
46+
// parse as topology token
47+
if a[0] == 't' {
48+
if _, err := NewTopologyTokenFromString(a); err != nil {
49+
t.Errorf("expected %q to pass, but got %q", a, err)
50+
}
51+
}
52+
53+
// parse as sync token
54+
if a[0] == 's' {
55+
if _, err := NewStreamTokenFromString(a); err != nil {
56+
t.Errorf("expected %q to pass, but got %q", a, err)
57+
}
58+
}
4259
}
4360

4461
shouldFail := []string{

0 commit comments

Comments
 (0)