forked from subutai-io/p2p
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdht_test.go
More file actions
40 lines (34 loc) · 745 Bytes
/
Copy pathdht_test.go
File metadata and controls
40 lines (34 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"testing"
"github.com/golang/protobuf/proto"
ptp "github.com/subutai-io/p2p/lib"
"github.com/subutai-io/p2p/protocol"
)
func TestRouteData(t *testing.T) {
dataStr := "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
dataArr := []string{}
i := 0
for i < 99 {
dataArr = append(dataArr, dataStr)
i++
}
data := []protocol.DHTPacket{
protocol.DHTPacket{},
protocol.DHTPacket{
Type: protocol.DHTPacketType_Ping,
},
protocol.DHTPacket{
Type: protocol.DHTPacketType_Ping,
Arguments: dataArr,
},
}
router := new(DHTRouter)
for _, d := range data {
b, _ := proto.Marshal(&d)
if len(b) > ptp.DHTBufferSize {
b = b[:ptp.DHTBufferSize]
}
router.routeData(b)
}
}