mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 15:03:09 -06:00
Fix parsing TopologyTokens
This commit is contained in:
parent
87f028db27
commit
27a20ec00d
|
|
@ -286,8 +286,8 @@ func NewTopologyTokenFromString(tok string) (token TopologyToken, err error) {
|
||||||
if i > len(positions) {
|
if i > len(positions) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var pos int
|
var pos int64
|
||||||
pos, err = strconv.Atoi(p)
|
pos, err = strconv.ParseInt(p, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,27 @@ func TestSyncTokens(t *testing.T) {
|
||||||
"s3_1_0_0_0_0_2_0_5": StreamingToken{3, 1, 0, 0, 0, 0, 2, 0, 5}.String(),
|
"s3_1_0_0_0_0_2_0_5": StreamingToken{3, 1, 0, 0, 0, 0, 2, 0, 5}.String(),
|
||||||
"s3_1_2_3_5_0_0_0_6": StreamingToken{3, 1, 2, 3, 5, 0, 0, 0, 6}.String(),
|
"s3_1_2_3_5_0_0_0_6": StreamingToken{3, 1, 2, 3, 5, 0, 0, 0, 6}.String(),
|
||||||
"t3_1": TopologyToken{3, 1}.String(),
|
"t3_1": TopologyToken{3, 1}.String(),
|
||||||
|
"t9223372036854775807_9223372036854775807": TopologyToken{Depth: 9223372036854775807, PDUPosition: 9223372036854775807}.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
for a, b := range shouldPass {
|
for a, b := range shouldPass {
|
||||||
if a != b {
|
if a != b {
|
||||||
t.Errorf("expected %q, got %q", a, b)
|
t.Errorf("expected %q, got %q", a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse as topology token
|
||||||
|
if a[0] == 't' {
|
||||||
|
if _, err := NewTopologyTokenFromString(a); err != nil {
|
||||||
|
t.Errorf("expected %q to pass, but got %q", a, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse as sync token
|
||||||
|
if a[0] == 's' {
|
||||||
|
if _, err := NewStreamTokenFromString(a); err != nil {
|
||||||
|
t.Errorf("expected %q to pass, but got %q", a, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldFail := []string{
|
shouldFail := []string{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue