Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kbucket
Commits
191c1d32
Commit
191c1d32
authored
May 19, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run 'gofmt -s -w' on these files
parent
ea04d1b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
xor_test.go
xor_test.go
+15
-15
No files found.
xor_test.go
View file @
191c1d32
...
...
@@ -10,9 +10,9 @@ import (
func
TestPrefixLen
(
t
*
testing
.
T
)
{
cases
:=
[][]
byte
{
[]
byte
{
0x00
,
0x00
,
0x00
,
0x80
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0x00
,
0x58
,
0xFF
,
0x80
,
0x00
,
0x00
,
0xF0
},
{
0x00
,
0x00
,
0x00
,
0x80
,
0x00
,
0x00
,
0x00
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x00
,
0x58
,
0xFF
,
0x80
,
0x00
,
0x00
,
0xF0
},
}
lens
:=
[]
int
{
24
,
56
,
9
}
...
...
@@ -28,15 +28,15 @@ func TestPrefixLen(t *testing.T) {
func
TestXorKeySpace
(
t
*
testing
.
T
)
{
ids
:=
[][]
byte
{
[]
byte
{
0xFF
,
0xFF
,
0xFF
,
0xFF
},
[]
byte
{
0x00
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0xFF
,
0xFF
,
0xFF
,
0xF0
},
{
0xFF
,
0xFF
,
0xFF
,
0xFF
},
{
0x00
,
0x00
,
0x00
,
0x00
},
{
0xFF
,
0xFF
,
0xFF
,
0xF0
},
}
ks
:=
[][
2
]
Key
{
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
0
]),
XORKeySpace
.
Key
(
ids
[
0
])},
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
1
]),
XORKeySpace
.
Key
(
ids
[
1
])},
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
2
]),
XORKeySpace
.
Key
(
ids
[
2
])},
{
XORKeySpace
.
Key
(
ids
[
0
]),
XORKeySpace
.
Key
(
ids
[
0
])},
{
XORKeySpace
.
Key
(
ids
[
1
]),
XORKeySpace
.
Key
(
ids
[
1
])},
{
XORKeySpace
.
Key
(
ids
[
2
]),
XORKeySpace
.
Key
(
ids
[
2
])},
}
for
i
,
set
:=
range
ks
{
...
...
@@ -75,12 +75,12 @@ func TestXorKeySpace(t *testing.T) {
func
TestDistancesAndCenterSorting
(
t
*
testing
.
T
)
{
adjs
:=
[][]
byte
{
[]
byte
{
173
,
149
,
19
,
27
,
192
,
183
,
153
,
192
,
177
,
175
,
71
,
127
,
177
,
79
,
207
,
38
,
166
,
169
,
247
,
96
,
121
,
228
,
139
,
240
,
144
,
172
,
183
,
232
,
54
,
123
,
253
,
14
},
[]
byte
{
223
,
63
,
97
,
152
,
4
,
169
,
47
,
219
,
64
,
87
,
25
,
45
,
196
,
61
,
215
,
72
,
234
,
119
,
138
,
220
,
82
,
188
,
73
,
140
,
232
,
5
,
36
,
192
,
20
,
184
,
17
,
25
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
126
},
[]
byte
{
73
,
0
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
173
,
149
,
19
,
27
,
192
,
183
,
153
,
192
,
177
,
175
,
71
,
127
,
177
,
79
,
207
,
38
,
166
,
169
,
247
,
96
,
121
,
228
,
139
,
240
,
144
,
172
,
183
,
232
,
54
,
123
,
253
,
14
},
{
223
,
63
,
97
,
152
,
4
,
169
,
47
,
219
,
64
,
87
,
25
,
45
,
196
,
61
,
215
,
72
,
234
,
119
,
138
,
220
,
82
,
188
,
73
,
140
,
232
,
5
,
36
,
192
,
20
,
184
,
17
,
25
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
126
},
{
73
,
0
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
}
keys
:=
make
([]
Key
,
len
(
adjs
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment