forked from anacrolix/torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bep40_test.go
34 lines (31 loc) · 1.05 KB
/
bep40_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
package torrent
import (
"net"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBep40Priority(t *testing.T) {
assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
))
assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
))
assert.Equal(t, peerPriority(0x99568189), bep40PriorityIgnoreError(
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
))
assert.Equal(t, peerPriority(0x2b41d456), bep40PriorityIgnoreError(
IpPort{IP: net.ParseIP("206.248.98.111"), Port: 0},
IpPort{IP: net.ParseIP("142.147.89.224"), Port: 0},
))
assert.EqualValues(t, "\x00\x00\x00\x00", func() []byte {
b, _ := bep40PriorityBytes(
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
)
return b
}())
}