-
Notifications
You must be signed in to change notification settings - Fork 5
/
node_info_test.go
39 lines (34 loc) · 2.27 KB
/
node_info_test.go
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
package dht
import (
"bytes"
"testing"
)
func TestCompactNodeInfos(t *testing.T) {
var nodesLength = 16
var b = []byte{
59, 140, 115, 79, 59, 122, 27, 184, 61, 205, 8, 65, 112, 57, 84, 57, 163, 195, 155, 48, 174, 88, 226, 182, 162, 51,
200, 45, 219, 42, 71, 79, 161, 180, 230, 240, 250, 55, 11, 217, 115, 237, 88, 173, 54, 62, 109, 31, 232, 5, 159, 102,
53, 162, 19, 255, 57, 127, 168, 144, 154, 173, 9, 2, 49, 235, 112, 3, 175, 81, 48, 13, 71, 112, 192, 66, 55, 245,
178, 175, 52, 173, 79, 16, 193, 223, 91, 10, 117, 50, 219, 102, 49, 153, 120, 187, 9, 111, 125, 38, 183, 22, 26, 225,
218, 161, 173, 64, 74, 170, 51, 52, 163, 181, 130, 141, 94, 38, 68, 133, 91, 116, 124, 203, 128, 74, 65, 8, 26, 225,
231, 195, 77, 78, 214, 182, 239, 211, 204, 128, 169, 202, 134, 183, 120, 191, 196, 94, 237, 111, 59, 174, 145, 195, 200, 213,
164, 225, 85, 76, 64, 254, 167, 243, 105, 102, 1, 108, 169, 229, 13, 240, 103, 16, 154, 41, 175, 194, 206, 17, 56, 197,
4, 25, 213, 149, 9, 61, 218, 71, 90, 145, 248, 85, 74, 46, 242, 239, 129, 97, 0, 254, 108, 239, 125, 252, 4, 0,
54, 74, 174, 161, 236, 213, 167, 148, 235, 223, 228, 231, 128, 178, 196, 202, 146, 99, 182, 10, 93, 79, 210, 160, 58, 3,
20, 253, 241, 17, 228, 32, 112, 202, 80, 179, 134, 15, 28, 60, 94, 150, 44, 57, 127, 112, 187, 75, 98, 150, 136, 151,
154, 154, 50, 226, 89, 230, 100, 210, 41, 223, 63, 29, 29, 3, 197, 29, 72, 42, 129, 137, 89, 64, 33, 233, 89, 58,
71, 8, 180, 131, 165, 76, 233, 120, 189, 118, 62, 240, 92, 57, 199, 74, 96, 45, 223, 215, 118, 167, 101, 65, 63, 13,
232, 243, 68, 139, 65, 41, 55, 143, 188, 17, 24, 62, 137, 91, 166, 119, 149, 47, 187, 114, 116, 224, 56, 141, 26, 225,
185, 125, 145, 250, 230, 94, 196, 82, 119, 48, 222, 92, 178, 203, 6, 64, 11, 228, 90, 136, 190, 9, 194, 32, 23, 24,
206, 177, 174, 31, 3, 90, 125, 9, 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 139, 188, 163, 85, 99, 232, 82,
162, 47, 177, 44, 104, 40, 72, 3, 68, 88, 146, 51, 208, 162, 50, 177, 162, 111, 91, 30, 188, 239, 34, 117, 186, 3,
}
nodes := UnCompactNodeInfos(b)
if len(nodes) != nodesLength {
t.Errorf("UnCompactNodeInfos expected to return %d node, got %d", nodesLength, len(nodes))
}
out := CompactNodeInfos(nodes)
if !bytes.Equal(b, out) {
t.Error("CompactNodeInfos output is different with input")
}
}