优化代码

This commit is contained in:
刘祥超
2023-08-08 11:10:51 +08:00
parent ae74114fca
commit f034a1cfb3

View File

@@ -1,11 +1,7 @@
package nodes package nodes
import ( import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/golang/protobuf/proto"
_ "github.com/iwind/TeaGo/bootstrap" _ "github.com/iwind/TeaGo/bootstrap"
"io"
"strconv"
"testing" "testing"
) )
@@ -22,29 +18,3 @@ func TestNode_Test(t *testing.T) {
} }
t.Log("ok") t.Log("ok")
} }
func TestNode_Proto_Buffer(t *testing.T) {
buff := proto.NewBuffer([]byte{})
for i := 0; i < 10; i++ {
err := buff.EncodeMessage(&pb.NodeStreamMessage{
RequestId: int64(i),
Code: "msg" + strconv.Itoa(i),
})
if err != nil {
t.Fatal(err)
}
}
for i := 0; i < 11; i++ {
msg := &pb.NodeStreamMessage{}
err := buff.DecodeMessage(msg)
if err != nil {
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
} else {
t.Fatal(err)
}
}
t.Log(msg.Code, msg.RequestId)
}
}