mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
能连接和通讯,还未解析数据
This commit is contained in:
25
protocol/frame_test.go
Normal file
25
protocol/frame_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFrame_Bytes(t *testing.T) {
|
||||
f := Frame{
|
||||
MsgID: 1,
|
||||
Control: 1,
|
||||
Type: Connect,
|
||||
Data: []byte{0x01},
|
||||
}
|
||||
hex := f.Bytes().HEX()
|
||||
t.Log(hex)
|
||||
if hex != "0c0100000001030003000d0001" {
|
||||
t.Error("编码错误")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBytes(t *testing.T) {
|
||||
t.Log(hex.EncodeToString(Bytes(uint32(1))))
|
||||
t.Log(hex.EncodeToString(Bytes(uint16(0x0d00))))
|
||||
}
|
||||
Reference in New Issue
Block a user