From 27fb1426d9444cd7ddf9a7221bf407543c991433 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 17:34:03 +0200 Subject: [PATCH] android: cover decimal channel IDs from SM in avatar regression tests --- .../java/com/utun/chat/data/AvatarProtocolTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/chatgui-android/app/src/test/java/com/utun/chat/data/AvatarProtocolTest.kt b/tools/chatgui-android/app/src/test/java/com/utun/chat/data/AvatarProtocolTest.kt index 1085cf61..ad1c537c 100644 --- a/tools/chatgui-android/app/src/test/java/com/utun/chat/data/AvatarProtocolTest.kt +++ b/tools/chatgui-android/app/src/test/java/com/utun/chat/data/AvatarProtocolTest.kt @@ -28,6 +28,19 @@ class AvatarProtocolTest { .forEach { assertFalse(it, AvatarProtocol.validFile(it)) } assertEquals(0L, AvatarProtocol.node("invalid")) } + @Test fun channelsUseDecimalIdsAndAvatarServersUseHex() { + // Реальные channel_id с SM: прежний hex-парсер превращал 19 цифр в 0. + listOf(7215665410053680736L, 7206723622466219923L, 1003157353743339669L, 123L).forEach { id -> + assertEquals(id, AvatarProtocol.groupId(id.toString())) + val event = group().also { ByteBuffer.wrap(it).order(ByteOrder.LITTLE_ENDIAN).putLong(8, id) } + assertEquals(AvatarProtocol.groupId(id.toString()), AvatarProtocol.group(event).group) + } + assertEquals(1751929779338959921L, AvatarProtocol.node("18501ada28ed5c31")) + assertEquals(-1L, AvatarProtocol.groupId("18446744073709551615")) + listOf("18446744073709551616", "-1", "18501ada28ed5c31", "invalid", "").forEach { + assertEquals(it, 0L, AvatarProtocol.groupId(it)) + } + } @Test fun groupLimitAndSignedDeletion() { val record = AvatarProtocol.group(group(16384)) assertEquals(71L, record.id); assertEquals(uid, record.group); assertEquals(123L, record.version)