rpc: add android login startup compat
(cherry picked from commit 53904e72f7c3b96e6ae5e24196d0e551fa8aebce)
This commit is contained in:
parent
82dd2996e6
commit
294e994272
7 changed files with 127 additions and 3 deletions
|
|
@ -34,6 +34,51 @@ func TestLangpackGetLanguagesCurrentAndLegacy(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestLegacyLangpackGetLangPack(t *testing.T) {
|
||||
r := New(Config{DC: 2, IP: "127.0.0.1", Port: 2398}, Deps{}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
var in bin.Buffer
|
||||
in.PutID(legacyLangpackGetLangPackTypeID)
|
||||
in.PutString("en")
|
||||
enc, err := r.Dispatch(androidClientContext(), [8]byte{}, 0, &in)
|
||||
if err != nil {
|
||||
t.Fatalf("dispatch legacy langpack.getLangPack: %v", err)
|
||||
}
|
||||
var out bin.Buffer
|
||||
if err := enc.Encode(&out); err != nil {
|
||||
t.Fatalf("encode response: %v", err)
|
||||
}
|
||||
var diff tg.LangPackDifference
|
||||
if err := diff.Decode(&out); err != nil {
|
||||
t.Fatalf("decode response: %v", err)
|
||||
}
|
||||
if diff.LangCode != "en" {
|
||||
t.Fatalf("difference = %+v, want lang_code=en", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyLangpackGetStrings(t *testing.T) {
|
||||
r := New(Config{DC: 2, IP: "127.0.0.1", Port: 2398}, Deps{}, zaptest.NewLogger(t), clock.System)
|
||||
|
||||
var in bin.Buffer
|
||||
in.PutID(legacyLangpackGetStringsTypeID)
|
||||
in.PutString("en")
|
||||
in.PutVectorHeader(1)
|
||||
in.PutString("lng_intro_about")
|
||||
enc, err := r.Dispatch(androidClientContext(), [8]byte{}, 0, &in)
|
||||
if err != nil {
|
||||
t.Fatalf("dispatch legacy langpack.getStrings: %v", err)
|
||||
}
|
||||
var out bin.Buffer
|
||||
if err := enc.Encode(&out); err != nil {
|
||||
t.Fatalf("encode response: %v", err)
|
||||
}
|
||||
var strings tg.LangPackStringClassVector
|
||||
if err := strings.Decode(&out); err != nil {
|
||||
t.Fatalf("decode response: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func assertLangpackLanguages(t *testing.T, r *Router, ctx context.Context, in *bin.Buffer) {
|
||||
t.Helper()
|
||||
enc, err := r.Dispatch(ctx, [8]byte{}, 0, in)
|
||||
|
|
@ -52,3 +97,11 @@ func assertLangpackLanguages(t *testing.T, r *Router, ctx context.Context, in *b
|
|||
t.Fatalf("languages = %+v, want English entry", langs.Elems)
|
||||
}
|
||||
}
|
||||
|
||||
func androidClientContext() context.Context {
|
||||
return WithClientInfo(context.Background(), ClientInfo{
|
||||
DeviceModel: "Android",
|
||||
AppVersion: "12.7.3",
|
||||
LangCode: "en",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue