]> Sergey Matveev's repositories - btrtrc.git/blob - bep40_test.go
gorond
[btrtrc.git] / bep40_test.go
1 package torrent
2
3 import (
4         "net"
5         "testing"
6
7         "github.com/stretchr/testify/assert"
8 )
9
10 func TestBep40Priority(t *testing.T) {
11         assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
12                 IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
13                 IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
14         ))
15         assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
16                 IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
17                 IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
18         ))
19         assert.Equal(t, peerPriority(0x99568189), bep40PriorityIgnoreError(
20                 IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
21                 IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
22         ))
23         assert.Equal(t, peerPriority(0x2b41d456), bep40PriorityIgnoreError(
24                 IpPort{IP: net.ParseIP("206.248.98.111"), Port: 0},
25                 IpPort{IP: net.ParseIP("142.147.89.224"), Port: 0},
26         ))
27         assert.EqualValues(t, "\x00\x00\x00\x00", func() []byte {
28                 b, _ := bep40PriorityBytes(
29                         IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
30                         IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
31                 )
32                 return b
33         }())
34 }