feat: 接入端到端 demo 与签名变体
- Flutter 桌面端通过 dart:ffi 调用 Rust Core cdylib - 实现 ECDH P-256 密钥协商、HKDF 子密钥派生、AES-256-GCM 控制帧 - Android 被控端用派生密钥做控制帧加密与媒体包 MAC - 新增 libopus JNI 骨架,默认回退 MediaCodec - 新增 aosp/zhanxun/neutral 签名变体与系统 sharedUserId - 本机独立信令服务与设置页开关 - 新增 .gitignore 排除所有编译产物与打包目录
This commit is contained in:
commit
31b9a52eb4
154 files changed
+13287
No files matched your search
@@ -0,0 +1,40 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user