tracker: Skip DNS error in UDP test

This commit is contained in:
Matt Joiner 2016-05-07 18:17:40 +10:00
parent 9c36d36654
commit d5d3d9f623
1 changed files with 8 additions and 10 deletions

View File

@ -125,27 +125,25 @@ func TestUDPTracker(t *testing.T) {
if testing.Short() { if testing.Short() {
t.SkipNow() t.SkipNow()
} }
// if err := tr.Connect(); err != nil {
// if strings.Contains(err.Error(), "no such host") {
// t.Skip(err)
// }
// if strings.Contains(err.Error(), "i/o timeout") {
// t.Skip(err)
// }
// t.Fatal(err)
// }
req := AnnounceRequest{ req := AnnounceRequest{
NumWant: -1, NumWant: -1,
// Event: Started,
} }
rand.Read(req.PeerId[:]) rand.Read(req.PeerId[:])
copy(req.InfoHash[:], []uint8{0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1}) copy(req.InfoHash[:], []uint8{0xa3, 0x56, 0x41, 0x43, 0x74, 0x23, 0xe6, 0x26, 0xd9, 0x38, 0x25, 0x4a, 0x6b, 0x80, 0x49, 0x10, 0xa6, 0x67, 0xa, 0xc1})
ar, err := Announce("udp://tracker.openbittorrent.com:80/announce", &req) ar, err := Announce("udp://tracker.openbittorrent.com:80/announce", &req)
// Skip temporary errors as we don't control the server.
if ne, ok := err.(net.Error); ok { if ne, ok := err.(net.Error); ok {
if ne.Timeout() { if ne.Timeout() {
t.Skip(err) t.Skip(err)
} }
} }
// Skip DNS errors because the network might not be available, and we
// don't control the domains we're testing.
if oe, ok := err.(*net.OpError); ok {
if _, ok := oe.Err.(*net.DNSError); ok {
t.Skip(err)
}
}
require.NoError(t, err) require.NoError(t, err)
t.Log(ar) t.Log(ar)
} }