fix: 推送 meta 用 UseNumber 保留超过 2^53 的整数

This commit is contained in:
Nixevol
2026-09-30 16:21:05 +08:00
parent aa24e974af
commit 2461bec3b6
3 changed files with 46 additions and 3 deletions
+35
View File
@@ -1,6 +1,7 @@
package message
import (
"bytes"
"context"
"database/sql"
"encoding/json"
@@ -742,3 +743,37 @@ func TestPushRevokedOnRecallAfterPush(t *testing.T) {
t.Fatal("expected revoked frame")
}
}
func TestPushPreservesLargeMetaInteger(t *testing.T) {
t.Parallel()
raw := `{"id":12345678901234567890}`
decoded := decodeMetaJSON(raw)
n, ok := decoded["id"].(json.Number)
if !ok || n.String() != "12345678901234567890" {
t.Fatalf("decode meta=%v", decoded)
}
e := openDeliveryEnv(t, nil)
insertEndpoint(t, e.db, "alice", "", 1, 0)
insertEndpoint(t, e.db, "bob", "", 1, 0)
e.online("bob", "c-bob")
ctx := context.Background()
req := baseSend("meta-big", "bob")
req.Meta = map[string]any{"id": json.Number("12345678901234567890")}
if _, err := e.app.Submit(ctx, "alice", port.ConnInfo{}, req); err != nil {
t.Fatal(err)
}
if err := e.app.PushPending(ctx, "bob", "c-bob"); err != nil {
t.Fatal(err)
}
found := false
for _, p := range e.down.Snapshots() {
if bytes.Contains(p.Payload, []byte("12345678901234567890")) {
found = true
break
}
}
if !found {
t.Fatalf("push payloads missing large int: %v", e.down.Snapshots())
}
}