-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FriendNickChangedEvent, fix #1536
- Loading branch information
Showing
3 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
mirai-core/src/commonTest/kotlin/notice/processors/FriendNickChangeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright 2019-2021 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/dev/LICENSE | ||
*/ | ||
|
||
@file:JvmBlockingBridge | ||
|
||
package net.mamoe.mirai.internal.notice.processors | ||
|
||
import net.mamoe.kjbb.JvmBlockingBridge | ||
import net.mamoe.mirai.event.events.FriendNickChangedEvent | ||
import net.mamoe.mirai.internal.network.protocol.data.jce.MsgInfo | ||
import net.mamoe.mirai.internal.network.protocol.data.jce.MsgType0x210 | ||
import net.mamoe.mirai.internal.network.protocol.data.jce.ShareData | ||
import net.mamoe.mirai.internal.network.protocol.data.proto.Submsgtype0x27.SubMsgType0x27 | ||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertIs | ||
|
||
internal class FriendNickChangeTest : AbstractNoticeProcessorTest() { | ||
|
||
@Test | ||
suspend fun `nick changed`() { | ||
// FriendNickChangedEvent 内容异常 https://github.com/mamoe/mirai/issues/1356 | ||
|
||
suspend fun runTest() = use { | ||
|
||
net.mamoe.mirai.internal.network.protocol.data.jce.OnlinePushPack.SvcReqPushMsg( | ||
uin = 1230002, | ||
uMsgTime = 1633037660, | ||
vMsgInfos = mutableListOf( | ||
MsgInfo( | ||
lFromUin = 1230002, | ||
shMsgType = 528, | ||
shMsgSeq = 142, | ||
strMsg = "", | ||
uRealMsgTime = 160, | ||
vMsg = MsgType0x210( | ||
uSubMsgType = 39, | ||
vProtobuf = SubMsgType0x27.SubMsgType0x27MsgBody( | ||
msgModInfos = mutableListOf( | ||
SubMsgType0x27.ForwardBody( | ||
opType = 20, | ||
msgModProfile = SubMsgType0x27.ModProfile( | ||
uin = 1230001, | ||
msgProfileInfos = mutableListOf( | ||
SubMsgType0x27.ProfileInfo( | ||
field = 20002, | ||
value = "ABC", | ||
) | ||
), | ||
), | ||
) | ||
), | ||
) | ||
.toByteArray(SubMsgType0x27.SubMsgType0x27MsgBody.serializer()), | ||
).toByteArray(), | ||
uAppShareID = 0, | ||
vMsgCookies = "08 90 04 10 90 84 A0 81 80 80 80 80 02 18 00 20 E3 86 03".hexToBytes(), | ||
lMsgUid = 14411, | ||
lLastChangeTime = 1, | ||
vCPicInfo = mutableListOf(), | ||
stShareData = ShareData( | ||
), | ||
lFromInstId = 0, | ||
vRemarkOfSender = net.mamoe.mirai.utils.EMPTY_BYTE_ARRAY, | ||
strFromMobile = "", | ||
strFromName = "", | ||
vNickName = mutableListOf(), | ||
) | ||
), | ||
svrip = 1273521418, | ||
) | ||
|
||
} | ||
|
||
setBot(1230002).apply { | ||
addFriend(1230001, nick = "aaa") | ||
} | ||
|
||
runTest().toList().run { | ||
assertEquals(1, size, toString()) | ||
get(0).run { | ||
assertIs<FriendNickChangedEvent>(this) | ||
assertEquals(1230001, friend.id) | ||
assertEquals("aaa", from) | ||
assertEquals("ABC", to) | ||
} | ||
} | ||
|
||
} | ||
} |
b0e25a5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1356