mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-22 14:30:26 +08:00
优化代码
This commit is contained in:
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user