- Flutter 桌面端通过 dart:ffi 调用 Rust Core cdylib - 实现 ECDH P-256 密钥协商、HKDF 子密钥派生、AES-256-GCM 控制帧 - Android 被控端用派生密钥做控制帧加密与媒体包 MAC - 新增 libopus JNI 骨架,默认回退 MediaCodec - 新增 aosp/zhanxun/neutral 签名变体与系统 sharedUserId - 本机独立信令服务与设置页开关 - 新增 .gitignore 排除所有编译产物与打包目录
41 lines
1004 B
Go
41 lines
1004 B
Go
package relay
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSendAndPoll(t *testing.T) {
|
|
store := New()
|
|
if err := store.Send("a", "b", json.RawMessage(`{"type":"offer"}`)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := store.Send("a", "b", json.RawMessage(`{"type":"candidate"}`)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
messages := store.Poll("b", 10)
|
|
if len(messages) != 2 {
|
|
t.Fatalf("期望 2 条消息,实际 %d", len(messages))
|
|
}
|
|
if string(messages[0].Payload) != `{"type":"offer"}` {
|
|
t.Fatalf("消息顺序错误: %s", messages[0].Payload)
|
|
}
|
|
if store.Size("b") != 0 {
|
|
t.Fatal("Poll 后队列应清空")
|
|
}
|
|
}
|
|
|
|
func TestExpiredMessagesAreDropped(t *testing.T) {
|
|
store := New()
|
|
now := time.Now()
|
|
store.now = func() time.Time { return now }
|
|
if err := store.Send("a", "b", json.RawMessage(`1`)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
now = now.Add(6 * time.Minute)
|
|
if messages := store.Poll("b", 10); len(messages) != 0 {
|
|
t.Fatalf("过期消息应被丢弃,实际 %+v", messages)
|
|
}
|
|
}
|