Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
x0x
dht
Commits
5215b74f
Commit
5215b74f
authored
Nov 03, 2019
by
Matt Joiner
Browse files
Add case for duplicate Id and different Addr to TestNodesByDistance
parent
a3c1a891
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
misc_test.go
misc_test.go
+14
-3
No files found.
misc_test.go
View file @
5215b74f
...
...
@@ -5,6 +5,8 @@ import (
"github.com/anacrolix/missinggo/v2/iter"
"github.com/stretchr/testify/assert"
"github.com/anacrolix/dht/v2/krpc"
)
func
TestNodesByDistance
(
t
*
testing
.
T
)
{
...
...
@@ -22,24 +24,33 @@ func TestNodesByDistance(t *testing.T) {
i
.
bits
[
12
]
=
1
return
&
i
}()},
addrMaybeId
{
Addr
:
krpc
.
NodeAddr
{
Port
:
1
}},
}
push
:=
func
(
i
int
)
{
a
=
a
.
Add
(
amis
[
i
])
}
push
(
4
)
push
(
2
)
push
(
0
)
push
(
3
)
push
(
0
)
push
(
1
)
pop
:=
func
(
i
int
)
{
pop
:=
func
(
i
s
...
int
)
{
first
,
ok
:=
iter
.
First
(
a
.
Iter
)
assert
.
True
(
t
,
ok
)
assert
.
Equal
(
t
,
amis
[
i
],
first
)
assert
.
Contains
(
t
,
func
()
(
ret
[]
addrMaybeId
)
{
for
_
,
i
:=
range
is
{
ret
=
append
(
ret
,
amis
[
i
])
}
return
}(),
first
)
a
=
a
.
Delete
(
first
)
}
pop
(
1
)
pop
(
2
)
pop
(
3
)
pop
(
0
)
pop
(
0
,
4
)
pop
(
0
,
4
)
//pop(0, 4)
assert
.
EqualValues
(
t
,
0
,
a
.
Len
())
}
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