6 "github.com/stretchr/testify/assert"
7 "github.com/stretchr/testify/require"
9 "github.com/anacrolix/torrent/bencode"
12 var defaultHTTPUserAgent = "Go-Torrent"
14 func TestUnmarshalHTTPResponsePeerDicts(t *testing.T) {
16 require.NoError(t, bencode.Unmarshal([]byte("d5:peersl"+
17 "d2:ip7:1.2.3.47:peer id20:thisisthe20bytepeeri4:porti9999ee"+
18 "d7:peer id20:thisisthe20bytepeeri2:ip39:2001:0db8:85a3:0000:0000:8a2e:0370:73344:porti9998ee"+
20 ps, err := hr.UnmarshalPeers()
21 require.NoError(t, err)
23 assert.Equal(t, []byte("thisisthe20bytepeeri"), ps[0].ID)
24 assert.EqualValues(t, 9999, ps[0].Port)
25 assert.EqualValues(t, 9998, ps[1].Port)
26 assert.NotNil(t, ps[0].IP)
27 assert.NotNil(t, ps[1].IP)