fix(rpc): sync verification icon envelope coverage
Follow up gramsrv#27 with the remaining peer-bearing messages.Messages boundaries and route-level wire regression coverage from the telesrv canonical implementation. Origin-PR: gramsrv#27 Origin-Head:f0bd6c9699Origin-Merge:7713847b2aCanonical: f1ba406015a2d5e37802b963757a5cac8ee3eb0e Co-authored-by: epilepticseizureee <business.egor.sg@gmail.com>
This commit is contained in:
parent
7713847b2a
commit
3fa0c6f1e4
12 changed files with 156 additions and 16 deletions
|
|
@ -65,6 +65,53 @@ func assertFlagBitDelta(t *testing.T, label string, before, after bin.Fields, wa
|
|||
}
|
||||
}
|
||||
|
||||
func assertMessagesEnvelopeBotVerificationIcon(t *testing.T, out tg.MessagesMessagesClass, peer domain.Peer, want int64) {
|
||||
t.Helper()
|
||||
var users []tg.UserClass
|
||||
var chats []tg.ChatClass
|
||||
switch value := out.(type) {
|
||||
case *tg.MessagesMessages:
|
||||
users, chats = value.Users, value.Chats
|
||||
case *tg.MessagesMessagesSlice:
|
||||
users, chats = value.Users, value.Chats
|
||||
case *tg.MessagesChannelMessages:
|
||||
users, chats = value.Users, value.Chats
|
||||
default:
|
||||
t.Fatalf("messages envelope = %T, want peer-bearing messages.Messages", out)
|
||||
}
|
||||
switch peer.Type {
|
||||
case domain.PeerTypeUser:
|
||||
for _, item := range users {
|
||||
user, ok := item.(*tg.User)
|
||||
if !ok || user.ID != peer.ID {
|
||||
continue
|
||||
}
|
||||
wire := &tg.User{}
|
||||
tlRoundTrip(t, user, wire)
|
||||
if icon, ok := wire.GetBotVerificationIcon(); !ok || icon != want {
|
||||
t.Fatalf("user %d bot_verification_icon = %d, ok=%v, want %d", peer.ID, icon, ok, want)
|
||||
}
|
||||
return
|
||||
}
|
||||
case domain.PeerTypeChannel:
|
||||
for _, item := range chats {
|
||||
channel, ok := item.(*tg.Channel)
|
||||
if !ok || channel.ID != peer.ID {
|
||||
continue
|
||||
}
|
||||
wire := &tg.Channel{}
|
||||
tlRoundTrip(t, channel, wire)
|
||||
if icon, ok := wire.GetBotVerificationIcon(); !ok || icon != want {
|
||||
t.Fatalf("channel %d bot_verification_icon = %d, ok=%v, want %d", peer.ID, icon, ok, want)
|
||||
}
|
||||
return
|
||||
}
|
||||
default:
|
||||
t.Fatalf("unsupported verification peer %+v", peer)
|
||||
}
|
||||
t.Fatalf("messages envelope %T does not carry peer %+v", out, peer)
|
||||
}
|
||||
|
||||
// TestBotVerificationConstructorIDs pins the two constructor ids the feature
|
||||
// serialises. A drift here silently reshapes every payload below.
|
||||
func TestBotVerificationConstructorIDs(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue