Commit 5215b74f authored by Matt Joiner's avatar Matt Joiner
Browse files

Add case for duplicate Id and different Addr to TestNodesByDistance

parent a3c1a891
......@@ -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(is ...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())
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment